SSH Public Key Usage

Contributor Icon Contributed by Al Banks  
Tag Icon Tagged: OpenSSH  

Creation and distribution of SSH public keys for ease of access to remote machines.


First, create an SSH keypair on the client machine. In short, use:

ssh-keygen -t rsa

Note that you may want to change the keylength. Also, if you specify a password for the key, you will need to enter this password in order to connect to remote machines. Although not recommended, you can just hit enter for no password, and be able to access remote machines without a password.

Then, sftp the .ssh/id_rsa.pub to the remote machine. If this is the first time this has been done, you can:

sftp user@remote
put .ssh/id_rsa.pub authorized_keys

or, if other keys exist

put .ssh/id_rsa.pub username.pub
thenssh user@remote
cat username.pub >> .ssh/authorized_keys

At this point, you should be able, from the client machine:
ssh user@remote

and be granted access via the SSH public key.

The same key, in the id_rsa.pub file, can be copied in this manner to any other SSH hosts you wish to access.

 

1 Comment -


  1. Priya Chatterjee said on September 13, 2011

    Sometimes ssh keys get deleted from remote machine. What could be the reason for this? Also sometimes even if the keys are present system keeps on asking password

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -