Advertisement
Guest User

Untitled

a guest
Feb 25th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. # Copy ssh key to a remove server
  2. #################################
  3.  
  4. ssh-copy-id LOCAL_PATH_TO_THE_KEY USER_NAME@REMOTE_HOST:REMOTE_LOCATION
  5.  
  6. # ssh-copy-id may not be installed in the remote server. In that case, First create .ssh directory on remote server
  7. ssh USER_NAME@REMOTE_HOST:REMOTE_LOCATION "umask 077; test -d .ssh || mkdir .ssh"
  8.  
  9. ## cat local public key file and pipe over ssh to append the public key in the remote serve. Example-
  10. cat ~/.ssh/id_rsa.pub | ssh user@remote_ip_or_hostname "cat >> .ssh/authorized_keys"
  11.  
  12.  
  13.  
  14. # Copy file to the remote system
  15. #################################
  16.  
  17. # Basic scp command
  18. # From host to remote
  19. scp source_file_name dst_username@destination_host:destination_folder
  20.  
  21. # From remote to host
  22. scp dst_username@destination_host:destination_file ~/my_local_file.txt
  23. # or just download the file
  24. scp user@192.168.1.3:/some/path/file.txt
  25.  
  26. # Transfer multiple files
  27. # From host to remote
  28. scp foo.txt bar.txt username@remotehost:/path/directory/
  29.  
  30. # From remote to host
  31. scp username@remotehost:/path/directory/\{foo.txt,bar.txt\}
  32. # or just download
  33. scp root@192.168.1.3:~/\{abc.log,cde.txt\}
  34.  
  35. # To copy recusively use '-r' parameter
  36. scp -r ~/Downloads root@192.168.1.3:/root/Downloads
  37.  
  38. # Copy across two remote host
  39. scp user1@remotehost1:/some/remote/dir/foobar.txt user2@remotehost2:/some/remote/dir/
  40.  
  41. # For verbose output use the '-v' parameter
  42. scp -v Label.pdf mrarianto@202.x.x.x:.
  43.  
  44. # Speed up file transfer by using '-C'(Capital) to compress
  45. scp -vrC ~/Downloads root@192.168.1.3:/root/Downloads
  46.  
  47. # Limit bandwidth for transfer by using 'l' parameter
  48. scp -vrC -l 400 ~/Downloads root@192.168.1.3:/root/Downloads # bandwidth 4 kibt/s
  49.  
  50. # Connect to different port number on remote host
  51. scp -vC -P 2200 ~/test.txt root@192.168.1.3:/some/path/test.txt # remote port 2200
  52.  
  53. # '-p' option (smallcase), would preserve modification times, access times, and modes from the original file.
  54. scp -C -p ~/test.txt root@192.168.1.3:/some/path/test.txt
  55.  
  56. # To use specific key file use '-i' option
  57. scp -vCq -i private_key.pem ~/test.txt root@192.168.1.3:/some/path/test.txt
  58.  
  59. # To use different ssh_config file specify the file using '-F' option
  60. scp -vC -F /home/user/my_ssh_config ~/test.txt root@192.168.1.3:/some/path/test.txt
  61.  
  62. # Speed up the transfer by using different encryption(default AES). '-c' option to choose different cypher
  63. scp -c blowfish -C ~/local_file.txt username@remotehost:/remote/path/file.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement