To create and start using SSH keys you will need to login to your server using putty or what ever tool you have.

To create the SSH key you will need to run

ssh-keygen -t rsa -b 4096

You are then prompted with a few options you will be asked for the directory to save the key file to, default is fine

Enter file in which to save the key (/home/user/.ssh/id_rsa):

You have teh option to specify a passphrase/password for the key file this can be left blank of you do not want to have a passphrase

Enter passphrase (empty for no passphrase):

Now this should have completed and your keys have been created ready for use.
To allow access on another machine you now need to copy the public key to the servers authorized_keys file

ssh-copy-id user@10.10.10.2

or you can copy the contents of the id_rsa.pub file to the authorized_keys file

cat ~/.ssh/id_rsa.pub | ssh user@10.10.10.2 "cat >> ~/.ssh/authorized_keys"

you can now test this by trying to ssh into the server

ssh 10.10.10.2

You should now be logged into the server.
As an additional step you can disable root access to only all access via SSSH keys

To do this you will need to edit the sshd_config file and update the line for PermitRootLogin

vi /etc/ssh/sshd_config

PermitRootLogin without-password

once you have updated the file save and restart ssh

service ssh restart

Hope this helps you with the setup of SSH keys

Add a comment

0.0(0 votes)

Next Post Previous Post