Different Ways of File transfer to a remote server using ssh protocol

Different Ways of File transfer to a remote server using ssh protocol.

Scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.

Using scp from destination server

scp root@source_server:/path/to/file /path/here/
scp -P 2222 root@source_server:/path/to/file /path/here/ #with ssh port 2222
scp -r root@source_server:/path/to/directory/ /path/here/ #copy entire directory

Using scp from source server

scp /path/to/file root@destination_server:/detination/path/
scp -P 2222 /path/to/file root@destination_server:/detination/path/ #with ssh port 2222
scp -r /path/to/directory/ root@destination_server:/detination/path/ #copy entire directory

Using rsync from destination server

rsync -avz root@source_server:/path/to/file /path/here/
rsync -avz -e'ssh -p 2222' root@source_server:/path/to/file /path/here/ #with ssh port 2222
rsync -avz root@source_server:/path/to/directory/ /path/here/ #Copy contents of the directory only
rsync -avz root@source_server:/path/to/directory /path/here/ #Copy the entire directory *note the '/' at both commands

Using rsync from source server

rsync -avz /path/to/file root@destination_server:/detination/path/
rsync -avz -e'ssh -p 2222' /path/to/file root@destination_server:/detination/path/ #with ssh port 2222
Facebook Comments