Exchanging files with a Linux VM
We recommend the SCP
Both protocols tunnel TCP connections via SSH
Files are transferred using the same key pair as the one used for connecting to a Linux VM over SSH.
Exchanging files via SCP
To transfer a file named file1
from a local directory to a folder on the VM, run this command:
scp file1 <username>@<VM_IP_address>:<absolute_path_to_VM_folder>
To copy the file under a different name, specify a new file name in the destination address. For example, to save file1
to a remote folder as file1.txt
, run this command:
scp file1 <username>@<VM_IP_address>:<absolute_path_to_VM_folder>/file1.txt
To copy the entire directory contents, place the -r
key before the directory name:
scp -r <local_directory> <username>@<VM_IP_address>:<absolute_path_to_VM_folder>
To change the file exchange direction, specify the remote address before the local one. For example, to download a file named file2.txt
to your local computer, run this command:
scp <username>@server_ip:<absolute_path_to_VM_folder>/file2.txt <local_directory>
Exchanging files via SFTP
To use SFTP tools, establish a connection to a remote VM: To do this, run the following command:
sftp <username>@<VM_IP_address>
This command will switch the terminal to interactive mode on the remote server. Go to the destination folder on the remote VM by running this command:
cd <absolute_path_to_VM_folder>
To upload a file from your local computer to the selected folder on the remote VM, run this command:
put <path_to_file_on_local_computer>
To download a file from a remote VM, run the command below:
get <path_to_file_on_VM>
To copy the entire directory, use the -r
key in the put
and get
commands. For example, to copy all files from a local directory to a remote VM, run this command:
put -r <path_to_directory_on_local_computer>
Note
To copy files, the user must have write permissions for the folder on the destination server.
Exchanging files using client applications
You can use the following client applications to exchange files: