If your local computer runs a Linux or macOS operating system, you can use SFTP or SCP to upload local files to a Linux instance or download files from an Linux instance to your local computer.
Scenario
Operating system of local computer: Linux or macOS.
Operating system of the ECS instance: Linux.
File size: Not limited.
ImportantIf your want to upload files from or download files to a local computer that runs a Windows operating system, see Use WinSCP to upload files from or download files to a local computer that runs a Windows operating system.
You can also use Workbench or Cloud Assistant to upload and download files in the following scenarios. The operating system type of the local computer is not limited.
If a single file is not larger than 500 MB, you can use Workbench to upload or download the file. For more information, see Use Workbench to upload or download a file that is not larger than to a Linux instance.
If a single file is not larger than 24 KB, you can use Cloud Assistant to upload or download the file. For more information, see Upload on-premises files to ECS instances.
Prerequisite
The ECS instance is in the Running state.
The external public IP address of the ECS instance is obtained.
NoteIf your ECS instance cannot communicate with the Internet, you can associate the instance with an elastic IP address (EIP). For more information, see Associate or disassociate an EIP.
Port 22 is open in the inbound rule of the security group to which the instance belongs. For more information, see Add security group rules.
Run SFTP commands to upload or download files
Remotely connect the instance on the terminal.
sftp [The logon username]@[The public IP address of the instance]
Upload or download a file or a folder.
# Upload a file to the instance. put -r [The absolute path of the file or folder in the local computer] [The root directory that stores the file in the ECS instance] # Download the file to your local computer. get [The absolute path of the file or folder in the ECS instance] [The root directory that stores the file in the local computer]
Example: Run the following command to upload
/users/file.txt
in the local computer to the/home/ecs-user
directory in the ECS instance:put -r /users/file.txt /home/ecs-user
Run SCP commands to upload or download files
Upload local files to an ECS instance
scp [The absolute path of the local file] [The logon username]@[The public IP address of the instance]:[The root directory that stores the file in the instance]
Example:
Run the following command to upload /home/test001.txt in the local computer to the /home directory of the ECS instance whose public IP address is 121.40.XX.XX:
scp /home/test001.txt root@121.40.XX.XX:/home
Download a file to a local computer
scp [The logon username]@[The public IP address of the instance]:[The absolute path of the file in the ECS instance] [The root directory that stores the file in the local computer]
Example:
Run the following command to download the /home/test001.txt in the ECS instance whose public IP address is 121.43.XX.XX to the /home directory of the local computer:
scp root@121.43.XX.XX:/home/test001.txt /home
References
After you upload files to an ECS instance, you can back up these files. For more information, see Create a snapshot for a disk.
For more information about how to upload a local file to a Windows instance, see Upload or download a file to a Windows instance.
You can use Object Storage Service (OSS) to store and manage files. For more information, see Get started by using the OSS console.