Copying a file to another server through SSH

Expertise level: Medium

To copy a file to another server, use the following procedure:

  • Log in to your server with SSH as root.
  • Navigate to the directory where there are the files to be transferred, using cd command:
cd /path/to/the/directory/
  • Type the following command (make sure you replace the IP address and the file name):
scp file.txt

In this example, is the IP address of the destination server, and /root/ is the destination folder of file.txt.

  • You will be prompted to enter the root password of the remote server.

To copy a folder and its contents to another server, please use the following procedure:

If you need to copy a folder and its contents, you should use the -r (recursive) option with the command like this:

scp -r foldername

For more information on how to use the scp command, please consult this link:


Article is closed for comments.
Powered by Zendesk