maroph

SSH RSA key pair creation/distribution

Dec 16th, 2016
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.93 KB | None | 0 0
  1. # if directory ~/.ssh doesn't yet exist:
  2. mkdir ~/.ssh
  3. chmod 700 ~/.ssh
  4. #
  5. #
  6. cd ~/.ssh
  7. #
  8. # create a SSH RSA key pair for account user ($LOGNAME) on local machine host (uname -n)
  9. # no passphrase is needed (option -N '')
  10. ssh-keygen -f ssh_rsa_host_user -C "user@host" -t rsa -b 4096 -q -N ''
  11. #
  12. # adapt file permissions
  13. chmod 600 ssh_rsa_host_user
  14. chmod 644 ssh_rsa_host_user.pub
  15. #
  16. # print the fingerprint of the public key
  17. ssh-keygen -l -f ssh_rsa_host_user.pub
  18. # returns something similar to the following line
  19. # 4096 16:e9:60:f4:76:1e:43:07:dd:2f:b4:c2:e8:aa:90:a3 ssh_rsa_host_user.pub (RSA)
  20. #
  21. # create the ssh related default id files
  22. ln ssh_rsa_host_user id_rsa
  23. ln ssh_rsa_host_user.pub id_rsa.pub
  24. #
  25. # Distribution of the public key to another account (and machine):
  26. # copy SSH RSA public key to account ruser at host rhost
  27. ssh-copy-id -i ~/.ssh/id_rsa.pub ruser@rhost
  28. #
  29. # test access without password
  30. ssh ruser@rhost date
Advertisement
Add Comment
Please, Sign In to add comment