SCP is used to copy files securely over network. In order to use SCP, the remote host must be configured to use SSH server (OpenSSH on Linux system, including Ubuntu) and the user must have an account on remote server.
scp syntax is easy,
local:~$ scp <source> <username>@<remote_host>:<destination>
Example for copying local file to the users home directory on remote host, you can replace mypapit with your own username
local:~$ scp id_rsa_.pub mypapit@remote.host:~/
id_rsa.pub 100% 392 0.9KB/s 00:00
local:~$
To list the file on the remote directory, just run
local:~$ ssh mypapit@remote.host ls
temp_file.txt id_rsa.pub
and the content of remote directory will be displayed.
Copying file recursively
To copy file recursively, you only need to add “-r” switch. Add -v for verbose output.
Example:
local:~$ scp -rv ~/* username@remote.host:~/backup
Conclusion
SCP is easy to use especially when you want to copy or upload files from client to server without the use of FTP server. Additionally, the content of the files transfered is encrypted over SSH communication and you get the benefit of simplicity while working on the console.