I can copy the rsa key to the remote server for passwordless log-in. But I was told that there is another way to add this functionality using ssh-agent. I have run the commands generated by ssh-agent command. I did tried to add the key using ssh-add

$ ssh-add
Enter passphrase for /home/shantanu/.ssh/id_dsa: 
Identity added: /home/shantanu/.ssh/id_dsa (/home/shantanu/.ssh/id_dsa)

Does ssh-agent work the way I am trying to make it work?

  • Are you talking about sshing from client to server without a password, or sshing from client to server 1, then sshing from server 1 to server 2 without a password? – DerfK Aug 27 '11 at 20:27

The reason why you want this is propably because you want to do something automated on a remote server. Using ssh-agent or something similar is possibly no option, since you have to input the passphrase in an automated way, too.

Using keys without passphrase will do the job, but that is dangerous. So if you do it without passphrase:

  • Don`t use a priviledged account
  • You can limit the action to a single command in the authorized_keys file
  • If you need to copy things: Use a transfer account and use another local account to get the data from the transfer acccount

If your key has no passphrase (usually a bad thing) you don't need ssh-agent. You just put the public key into the authorized_keys file and off you go.

If however, your key does have a passphrase then you use ssh-agent (as well as putting the public key into the authorized_keys file), add the passphrase once (as you did above), and then for the rest of that session you don't have to use it again. For a new session you will have to add it again, this is usually a minor inconvenience.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.