Advertisement
Guest User

Untitled

a guest
Sep 14th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. ## Secure copy files across hosts
  2.  
  3. ### 1.Transfer single file
  4.  
  5. Open GIT BASH (to use Secure Copy), type below commands.
  6.  
  7. ```
  8. $cd /e/xampp/htdocs/projname
  9.  
  10. $touch README.md
  11. ```
  12.  
  13. To copy single file from local machine to remote machine in target directory
  14.  
  15. ```
  16. $scp -v README.md user@xx.xxx.xxx.xx:/var/www/projname
  17. ```
  18.  
  19. To copy single file from remote machine to local machine in current working directory(.)
  20.  
  21. ```
  22. $scp -v user@xx.xxx.xxx.xx:/var/www/projname/file.txt .
  23. ```
  24.  
  25. ### 2. Transfer multiple files
  26.  
  27. To copy multiple files from local directory to remote host
  28.  
  29. ```
  30. $scp foo.txt bar.txt user@xx.xxx.xxx.xx:/var/www/projname
  31. ```
  32.  
  33. To copy multiple files from remote host to current local directory
  34.  
  35. ```
  36. $scp user@xx.xxx.xxx.xx:/var/www/projname/\{foo.txt,bar.txt\} .
  37. ```
  38.  
  39. To copy an entire directory recursively from one host to another use the r switch and specify the directory
  40.  
  41. ```
  42. $scp -v -r ~/Downloads user@xx.xxx.xxx.xx:/var/www/projname
  43. ```
  44.  
  45. ### 3. Speed up the transfer with compression
  46.  
  47. A super cool option to speed up the transfer to save time and bandwidth. All you need to do is use the C option to enable compression. The files are compressed on the fly and decompressed on the destination.
  48.  
  49. ```
  50. $scp -vrC ~/Downloads user@xx.xxx.xxx.xx:/var/projname
  51.  
  52. $scp -vrC user@xx.xxx.xxx.xx:/var/www/projname/dirname .
  53. ```
  54.  
  55. In the above example we moved the entire directory with compression enabled. The speed gain would depend on how much the files could be compressed.
  56.  
  57. ### 4. Copy files across 2 remote hosts
  58.  
  59. ```
  60. $scp user1@remotehost1:/some/remote/dir/foobar.txt user2@remotehost2:/some/remote/dir/
  61. ```
  62.  
  63. #### Note:
  64. -v is verbose output (optional flag)
  65. -r is recursive flag
  66. -c is compression flag
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement