Hello everyone, on this tutorial I am going to show you some example on how to copy file over SSH. By learning this, you will be able to easily copy a file from local computer to remote one and vice versa. All can be done using Shell command via scp command. There is no special skills needed in order to be able to copy files over ssh. But a better understanding about SSH, Shell Commands are better.
On this tutorial, I use the following hosts:
- Local computer: 10.34.0.247
- Remote Computer: 10.34.0.166
First, we will list any files inside a directory.
[root@localhost ~]# ls file1.txt
As you can see my current directory has 2 files: file1.txt and anaconda-ks.cfg
Now we will copy the file1.txt to the remote host using scp command
[root@localhost ~]# scp file1.txt email@example.com:/home/dhani/ The authenticity of host '10.34.0.166 (10.34.0.166)' can't be established. ECDSA key fingerprint is 7e:d9:22:e7:5d:c4:cd:51:a1:75:43:f7:64:90:fe:88. Are you sure you want to continue connecting (yes/no)?
If this is the first time you connect to the remote host, you will need to confirm the authenticity of host as above. Type yes and press enter. The command will copy file1.txt to /home/dhani/ on the remote host. You can modify the command above to match your current needs.