Tuesday, January 29, 2013

Key-based ssh logins

Key-based authentication is a much more secure mode of authentication usable with (Open)SSH. It may provide a way for ssh automatic login. Here is the procedure to set up a client:

1. generate a key pair
The following command will generate RSA keys with a bit length of 4096 for use by SSH protocol version 2:

ssh-keygen -t rsa -b 4096


2. transfer client (public) key to server
The public key is normally stored in the file $HOME/.ssh/authorized_keys. This can be done by issuing:

ssh-copy-id -i server

where -i specifies that the key to be copied is stored in its default location ($HOME/.ssh/id_rsa.pub, in our example). In fact, it can be done by any your preferred method to move file from client to server.


For ssh automatic login, we need the help from ssh-agent, which allows us to store (using ssh-add, for example) our private key identities to the authentication agent.

No comments:

Post a Comment