How to copy a file between two Linux machines?

I'm connecting from a Linux server (Machine 1) to another Linux server (Machine 2) using PuTTY.

Using WinSCP, I have copied a zip file from my hard disk in Windows to the Machine 1's home directory.

How can I copy this zip file from the Machine 1 to the Machine 2's build/test_builds directory?

2

5 Answers

scp sourcefile ssh://[user]@[hostname]/[destination path]

I think this should work with every linux box with ssh enabled, maybe you'll need to enable secure copy (scp)

A better way to write this can be:

scp source destination

source and destination can be:

  • absolute or relative path to file (eg. /tmp/foo.txt or ./foo.txt)

  • ssh file path (in the form ssh://[user]@[machine]/[path]

You can also perform copies between machine1 and machine2, while being on machine3 (given that you've got access - eg. a logon to each machine) via:

scp ssh://user@machine1/path ssh://user@machine2/path

Hope this helps.

3

As per man I have changed the scp command as follows and it has worked for me.

scp user@sourceservername:sourcefilepath user@destservername:destdirectory

Hope this will help someone.

rsync -r --progress SRC DST

works also nice: retransfer, progress-bar

To transfer between two linux boxes use scp like the above user suggested. His syntax is a little off for ssh though. With scp the format is

scp [options] source destination

Which is available in the man pages man scp

for you the syntax from machine 1 is

scp /path/to/file.zip .2:port/path/to/destination/dir/

port default is 22

3
rsync -aPv --update /path/to/desire/file /path/to/destination/same_name_as_file

-a — archive mode, a combination of several other rsync options that is useful for backing up
-P — same as --partial --progress
-v--verbose

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like