All Products
Search
Document Center

Elastic Compute Service:use WinSCP to transfer files to a Linux instance from local Windows

Last Updated:Jan 21, 2025

If your local host runs on Windows, you can install WinSCP to establish a remote connection with a Linux ECS instance, enabling visual file uploads and downloads.

What is WinSCP?

WinSCP is a file transfer client for Windows users to securely replicate files to and from a Linux system. It offers a secure alternative to FTP, allowing server access with a username and password without additional server configurations.

Scenarios

  • Upload files: Transfer files from a Windows system to a Linux instance.

  • Download files: Retrieve files from a Linux instance to a Windows system.

Limits

  • File size: There are no restrictions.

  • Transfer speed: There are no restrictions.

  • Number of files: There are no restrictions.

  • Network requirements: The instance must be assigned a public IP or EIP.

Important

WinSCP is only compatible with Windows systems. For Linux or macOS, other file transfer methods are available. For more information, see the referenced document.

Preparations

  • Check the instance status: Ensure that the instance is in the Running state to perform the operations described in this topic.

    Check the instance running status

    You can verify the instance's status on the Instance page in the ECS console, as illustrated below:

    For more information, see the referenced document.

    image

  • Obtain the public IP address of the instance: The public IP address is required to connect to the instance for the operations described in this topic.

    Obtain the public IP information of the instance

    The public IP address can be found on the Instance page in the ECS console, as shown in the following image:

    For more information, see the referenced document. For details on enabling public access, see the referenced document.

    image

  • Check the security group of the instance: Verify that the security group settings permit connections to the SCP or SFTP port (default is port 22) for file transfers using WinSCP.

    Security group settings required for this operation

    To transfer files via SFTP using WinSCP, the SFTP port (default is 22) must be allowed in the inbound direction of the instance's security group. For details on configuring security group rules, see the referenced document.

    Authorization policy

    Priority

    Protocol type

    Port range

    Authorization object

    Allow

    1

    Custom TCP

    Configure it as your SFTP service port (default is 22).

    Configure it as the public address or IP address segment of your local computer.

    Warning

    Using 0.0.0.0/0 means that all IP addresses can connect to the remote service port. This configuration poses a security threat, so use it with caution.

    You can obtain your local IP address by visiting https://cip.cc/.

    For instance, if your local computer's IP is 118.xxx.xxx.xx8, the following configuration is necessary.

    image

Procedure

Important

For efficient transfer of large or multiple files, consider compressing them into a single package before uploading. For more information, see the referenced document.

Step 1: Connect to the instance using WinSCP

  1. Download and install WinSCP on your local Windows machine.

    For more information, visit the or the WinSCP official website.

  2. Launch WinSCP, and the Logon dialog box will appear.

  3. In the Session section, enter the following details.

    image

    The table below explains the configuration items.

    • File protocol: Choose either SFTP or SCP.

    • Hostname: Enter the public IP address of the Linux server.

    • Port number: The default is 22.

    • Username: Use the server login username, typically root.

    • Password: Enter the password you set when creating the Linux server.

      Note

      If you have forgotten the ECS instance password, you can reset it. For more information, see the referenced document.

      How to Log In Using a Key (Set a Key)

      For key-based login, follow the steps below to configure the key.

      1. In the Session section, click Advanced (A).

      2. In the Advanced Site Settings dialog, select SSH > Authentication. In the Key File (K) section, upload the key file for the Linux instance and click OK.

        image

      3. You can then log in to the instance without a password.

    After configuring, click Save to store the instance connection details for future use.

  4. Click Logon.

    This will take you to the WinSCP file transfer interface.

Step 2: Upload or download files

On the WinSCP file transfer page, the left panel represents your local directory, while the right panel shows the directory of the ECS instance.

  • Upload Files to the ECS Instance

    You can upload files to the ECS instance by dragging them from the left directory to the right directory.

    2025-01-08_14-34-26 (2)

  • Download Files to Local

    Drag and drop files from the right panel to the left to download them to your local machine.

    2025-01-08_14-38-05 (1)

FAQ

How to transfer files to a directory using sudo permissions? (For example, how ecs-user uses the upload function)

If you're logged in as a non-root user, such as ecs-user, and require sudo permissions to access certain directories, follow these steps when connecting to the instance:

  1. Determine the location of the sftp-server on the ECS instance.

    1. Log in to the instance using a suitable method.

      This example demonstrates login via Workbench. For more information, see the referenced document.
    2. Execute the following command in the command line to locate the sftp-server:

      sudo cat /etc/ssh/sshd_config |grep -i sftp-server

      The required location information is displayed as shown below.

      image

  2. In WinSCP, configure the SFTP server in the Advanced settings during the login setup.

    1. Click Advanced to access the Advanced Site Settings page.

    2. Enter the SFTP server details in the SFTP section.

      sudo su -c <location of the sftp-server obtained in Step 1>

      For instance, if the sftp-server is located at /usr/libexec/openssh/sftp-server, you would input the following configuration:

      sudo su -c /usr/libexec/openssh/sftp-server
    3. Click OK to proceed with logging into the instance.

    image

WinSCP Transfer is Slow or Unstable

WinSCP transfers data directly from your local machine to the instance, which can be affected by the intervening network. If you experience slow or unstable transfers, consider switching networks. Alternatively, you can use Object Storage Service (OSS) as an intermediary for file transfers, which does not incur traffic fees within the OSS intranet. For more information, see the referenced document.

References

  • After uploading files to an ECS instance, consider creating a backup. For more information, see the referenced document.

  • The methods described in this topic are specific to transferring files between a local Windows system and a Linux instance. For uploading files to a Windows instance, other methods are required. For more information, see the referenced document.

  • Object Storage Service (OSS) can also be used for file storage and management. For more information, see the referenced document.