SSh key passphrase and SSH Agent

It is recommended to protect the keys with a passphrase. it is straightforward to do so. In fact you will be asked to provide a passphrase to your private key during key generation and you can skip it if you want. In case you did skip it you can lock it again with a passphrase using the following.

$ ssh-keygen -p

Then it will prompt to put the key file path and you should enter then the password which must be more than five chrs.

Of course using keys is not only useful for security reasons, but also for not asking for password every time you use ssh. But thanks to ssh-agent we could save ourselves a few keystrokes, and more importantly use ssh in automated scripts without interrupting the script to prompt for passwords.

SSH Agent

$ eval `ssh-agent`
$ ssh-add /home/buddies/.ssh/buddies_rsa
$ ssh root@myremote.serverbuddies.com

We first ran the ssh agent, which is actually a service.

Then use ssh-add to add the key, then ssh the remote server with only the user name and the remote server address, without providing the key, and if you have protected the key with passphrase you will be asked for the passphrase when you add it.

The ssh-agent help in opening a session so we can use ssh to access remote server without giving any keys or password.

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.