Copying files from one linux server to another via SSH
Ever wanted to copy files from one linux server to another, via SSH? Here’s the command:
scp -P 22 -r /home/username/local-directory ip-or-hostname-of-remote-server:/home/username/remote-directory.
scp
= Secure Copy.
-r
= Recursive (copy the contents of the directory and the contents of any directories inside that directory).
-P
= (specifying the port number).
22
= The port number SSH is running on, on the remote server. (That’s right, some of us who are little security conscious, don’t leave SSH running on port 22).
/home/username/local-directory
= The local directory on the ‘source’ server, containing the files you want to copy to the remote servers
/home/username/remote-directory
= The directory on the ‘destination’ server, where you want to copy the files to.
ip-or-hostname-of-remote-server
= The example says it all. Replace this section with the remote IP Address or Hostname of the destination server.
Easy enough? If not, or you would like further examples or assistance, please feel free to ask you questions in the comments.