Linux 101 : SCP (Secure Copy) and SFTP (Secure FTP), copying files over the network



The SCP utility:

We use the below command to copy files remotely:


Server: Could be an IP address or hostname.

Example:

In the example below, we copy the file "file" from the local working directory on the local machine to the directory "/home/debian" on the remote machine (10.1.11.26).
The user must have the rights to copy the file on the remote directory:


We are asked for the user's password, then the file named "file" is copied to the remote destination in the "/home/debian" directory.

The SFTP utility:

We get connected to the remote host using the below command:


Example:

We connect to the remote host using its IP address (10.1.1.5).
We get connected as the user we are already logged in as:


Remark:

If we want to get connected as a different user, we use the below command:


To know which directory we are in on the remote machine, we use the below command:


To know in which directory we are in the local machine, we use the command "lpwd", which stands for "local pwd":


We copy the file "file" from the local working directory to the remote working directory using:


We can display the contents of the working directory on the remote machine using:


To remove the file "file" we use the below command:


For displaying the contents of the working directory on the local machine, we use "lls" which stands for "local ls":


To exit the "sftp" utility, we use:


Comments

Leave as a comment:

Archive