Insights

Copy file from one server to another using scp on linux

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/

Turn insight into action

Need help with apache or a related project?

If this article sparked an idea, question, or project direction, I can help you turn it into a practical next step.

Start a conversationChat on WhatsApp

Related reading

Articles connected to this topic

javascript

Custom Validation for Ninja Form – wordpress

Suppose you have used Ninja Form Plugin in your wordprss website. Ninja form provide you the option to validate the fields like email address, phone numbers format and required validation. But in case you have to add any custom validation then Ninja form provide you the hook to implement custom client side validation.

Jan 10, 2025

Read article

apache

401 Response when PHP-FPM Enabled on WordPress CMS

We recently migrated our website to another hosting service running FPM/FastCGI . We noticed under the website CMS -> tools -> Site Health Status , that all our REST API calls were failing authentication. It appeared to turn the request into an request from an Anonymous user even though we passed Basic Authentication h

Jan 2, 2025

Read article

css

How to find selected and unselected item in select2 dropdown

While using select2 library, if you have to find the selected and unselected item based on the change event when you check or uncheck the items. Based on the checked status, you may have to create some custom trigger or events then you can use the below code reference from codepen to achieve the save. […]

Dec 1, 2024

Read article

Most recent

Latest posts from the blog

View all articles →