Often times with a VPS or Dedicated Server you will need the ability to copy a single file or even an entire directory to another server. You can use FTP just like you normally would when uploading files to the server, but you can go one step better with SCP (Secure Copy Program).
If you wanted to copy a single file from one server to another server you issue the following command;
scp myfile.tar [email protected]:/your/directory/
If you wanted to copy an entire folder you can run this command;
scp -r myfolder [email protected]:/your/directory/
Copy one single file from a remote server to your current local server
scp [email protected]:/path/to/source-file /path/to/destination-folder
Let's say now you want to copy the same file from jane's home folder in
host.example.com to your local home folder.
scp [email protected]:/home/jane/table.csv /home/user/
Copy one single file from a remote server to another remote server
scp you can copy files between remote servers from a third server without the need to ssh into any of them, all weight lifting will be done by
scp [email protected]:/home/jane/table.csv [email protected]:/home/pete/
With SCP you will be asked for the password to the new server (unless you’ve already setup authentication keys). You can also requst files TO a server from the destination server. As always, the simple command from shell is “man scp” and it’ll bring up the entire manual with the various options you can use such as changing ports to shell in under etc.
Shell/Telnet must be enabled on the server in order to use SCP.