Sam's Tech Blog

'You can check out any time you like, But you can never leave!'

2019-08-21

Create strong SSH key for user

Create strong SSH key for user for password-less login using private and public keys

Create strong SSH key for user

Create strong SSH key for user for password-less login using private and public keys

#Create a very strong (4k type RSA) private and public key for client (sam)

ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_sam4k

#Edit /etc/ssh/ssh_config to load newly created private key

IdentityFile /home/sam/.ssh/id_rsa_sam4k

IdentityFile ~/.ssh/id_rsa

#Restartssh service on client

sudo /etc/init.d/ssh restart

#Copy new strong public key to server

ssh root@www.ic4.eu sh -c "'cat >> .ssh/authorized_keys'" < /home/sam/.ssh/id_rsa_sam4k.pub 

#Now you can login to server without password!

#You may need to edit servers /etc/ssh/sshd_config file and un-comment this line

#PubkeyAuthentication yes

#Restartssh service on server

sudo /etc/init.d/ssh restart