Difference between revisions of "Copy files to remote server"

From vpsget wiki
Jump to: navigation, search
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
How to copy files to remote server using command line
 
How to copy files to remote server using command line
  
1. Rsync.
+
1. Rsync. We are assuming that the ssh keys are already configured.
 
  rsync -av -e 'ssh -p22' /path/to/file IP:/path
 
  rsync -av -e 'ssh -p22' /path/to/file IP:/path
  
 
2. Scp
 
2. Scp
 
  scp -P 22 /path/to/file username@remoteserver.tld:/path/to/remote/directory/
 
  scp -P 22 /path/to/file username@remoteserver.tld:/path/to/remote/directory/
 +
 +
Add -r for recursive (copy all directory with subdirs):
 +
scp -r -P 22 /path/to/file username@remoteserver.tld:/path/to/remote/directory/
 +
 +
If you wan to resume broken scp transfer try with rsync:
 +
 +
rsync --append-verify --progress --rsh="ssh -p 4567" me@localhost:/path/to/large/file.gz
 +
 +
Better next time use rsync from beginning :)
 +
rsync --partial --progress --rsh=ssh user@host:remote_file local_file
 +
or
 +
rsync -avz -e ssh remoteuser@remotehost:/remote/path /local/path
  
 
[[Category:Admin area]]
 
[[Category:Admin area]]

Latest revision as of 06:05, 1 July 2015

How to copy files to remote server using command line

1. Rsync. We are assuming that the ssh keys are already configured.

rsync -av -e 'ssh -p22' /path/to/file IP:/path

2. Scp

scp -P 22 /path/to/file username@remoteserver.tld:/path/to/remote/directory/

Add -r for recursive (copy all directory with subdirs):

scp -r -P 22 /path/to/file username@remoteserver.tld:/path/to/remote/directory/

If you wan to resume broken scp transfer try with rsync:

rsync --append-verify --progress --rsh="ssh -p 4567" me@localhost:/path/to/large/file.gz 

Better next time use rsync from beginning :)

rsync --partial --progress --rsh=ssh user@host:remote_file local_file

or

rsync -avz -e ssh remoteuser@remotehost:/remote/path /local/path