If you have to copy any files from one server to another, you normally copy the same using FTP or wget. But some time wget function is disabled on server due to security reason.

Hence there is one more additional option that you can use to copy your file from another server to your server.

For that first, you need to login to the terminal ( through putty [on window]) using SSH (on Linux). Then navigate to the folder where you want to copy the file. The process is bidirectional. i.e. You can copy files from another server to your server and you can also copy files from your server to remote server. Full manual for SCP command is here https://www.commandlinux.com/man-page/man1/scp.1.html

Method 1: Push a file from one server to another server

Let’s say you have the file somefilename.zip on your server and you want to copy it to another server at IP address 219.xxx.xxx.xxx. To do this, log into your server and open a terminal (shell) window. Let’s say you have the same username on both the your serverand the remote server. With that in mind, to push the somefilename.zip file to the remote machine, you’d issue the command:

scp /path/to/somefilename.zip 219.xxx.xxx.xxx:/home/path/to/folder/onremote/server

You will be prompted for the user’s password and, upon successful authentication, the file will be copied.

Method 2: Copying a file from a remote server
Let’s say the somefilename.zip file is on a another server and you want to copy it to the local server. To do that, you’d issue the command:

scp remoteserveruser@219.xxx.xxx.xxx:/home/path/to/folder/onremote/server/somefilename.zip /save/path/folder_name/

Where /home/path/to/folder/onremote/server/ is the full path to the somefilename.zip file and remoteserveruser is the username on the remote server.

And, yes, again you’ll be prompted for the user password before the file is copied.

If your server has ssh enabled on specific port only then you can pass the port option like “-P” and specify the port number. Example

scp -P remoteserveruser@219.xxx.xxx.xxx:/home/path/to/folder/onremote/server/somefilename.zip /save/path/folder_name/

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.