Copy Files From One Linux Server to Another

Let’s say you have a file on your Linux server and want to copy it to another server. Or vice versa. You can also copy files from one remote server to another. An easy way to do this is with the scp tool, which is built on top of ssh.

Open a command line. The command will take the following format:

scp source destination

The source and destination can be either a local file path or a remote path. A local file path requires the same format you would use for cp (for example, /home/Me/Desktop/TestFile.txt). A remote path requires the remote user name, remote host name, and path on the server (for example, me@test.linuxserver.edu:/home/Me/Desktop/TestFile.txt). The path can use wildcards and can work for files or directories (the -r parameter will allow you to copy recursively). See scp –help for more details.

Some examples:

scp /home/Me/Desktop/TestFile.txt me@test.linuxserver.edu:/home/Me/Desktop/TestFile.txt
 
scp /home/Me/Desktop/*.txt me@test.linuxserver.edu:/home/Me/Desktop/
 
scp me@test.linuxserver.edu:/home/Me/Desktop/TestFile.txt /home/Me/Desktop/TestFile.txt
 
scp me@test.linuxserver.edu:/home/Me/Desktop/*.txt /home/Me/Desktop/

Leave a Reply