SCP Examples

How to secure copy a file from remote server to to local directory:
/home/user/file.txt = remote file
/home/user/Desktop/ = path to copy to local system


# scp -r user@remote.server.com:/home/user/file.txt /home/user/Desktop/

-r Recursively copy entire directories

What if the port is on 2243?

Use:

# scp -P2243 -r user@remote.server.com:/home/user/file.txt /home/user/Desktop/

# scp -P -r user@remote.server.com:/home/user/file.txt /home/user/Desktop/

-P port Specifies the port to connect to on the remote host. Note that this option is written with a capital ‘P’, because -p is already reserved for preserving the times and modes of the file in rcp(1).

-p Preserves modification times, access times, and modes from the original file.

Copy from local to remote:

# scp -P 22 file.txt root@192.168.1.1:/vmfs/volumes/datastore1/ISO

SCP with key

$ scp -i /home/admin/ipfs.pem FILE user@server:/home/admin/

Leave a Comment

Your email address will not be published. Required fields are marked *

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