maroph icon

SSH RSA key pair creation/distribution

maroph | PRO | 12/16/16 11:20:08 AM UTC | 0 ⭐ | 343 👁️ | Never ⏰ | []
Bash |

930 B

|

None

|

0 👍

/

0 👎

# if directory ~/.ssh doesn't yet exist:
mkdir ~/.ssh
chmod 700 ~/.ssh
#
#
cd ~/.ssh
#
# create a SSH RSA key pair for account user ($LOGNAME) on local machine host (uname -n)
# no passphrase is needed (option -N '')
ssh-keygen -f ssh_rsa_host_user -C "user@host" -t rsa -b 4096 -q -N ''
#
# adapt file permissions
chmod 600 ssh_rsa_host_user
chmod 644 ssh_rsa_host_user.pub
#
# print the fingerprint of the public key
ssh-keygen -l -f ssh_rsa_host_user.pub
# returns something similar to the following line
# 4096 16:e9:60:f4:76:1e:43:07:dd:2f:b4:c2:e8:aa:90:a3 ssh_rsa_host_user.pub (RSA)
#
# create the ssh related default id files
ln ssh_rsa_host_user id_rsa
ln ssh_rsa_host_user.pub id_rsa.pub
#
# Distribution of the public key to another account (and machine):
# copy SSH RSA public key to account ruser at host rhost
ssh-copy-id -i ~/.ssh/id_rsa.pub ruser@rhost
#
# test access without password
ssh ruser@rhost date

Comments