Copying files between boxes using ssh/scp

Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"

Top Level » System Level » SSH

Copying files between boxes using ssh/scpLast Modified: Oct 3, 2018, 4:53 pm
ssh is a protocol usually used to login to a system to alter files.  It can also be used for file transfers between systems.
scp is the software used to manage the ssh file transfer.

Let's make a few assumptions:
  • You're logged into box A with IP
  • You want to upload or download a file from remote box B with IP
  • Box B users SSH User login @
  • Remote box B uses ssh on port
  • Local file
  • Remote file

Push a file from A to B

If you want to push a file from A to B, you'd run:

scp -p -P 22 -C /path/to/A/local/file.txt admin@

Pull a file from B to A

The same idea is used to download a file from remote box B to the local box A, just swap the values:

scp -p -P 22 -C admin@ /path/to/A/local/file.txt

For both upload and download, they will ask you for your password on B.
If needed (eg: for background crons), you can automate the login process so A can connect to B without a password using an RSA Key.

For cron scp calls, we've received a report that you may need to run:

pkill ssh-agent

to clean up the scp calls.
Related Helpfiles
Automating ssh logins with an RSA key

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST