1

I am SSHing into my Amazon EC2 instance on a daily basis. In order to do so I have to provide the private key. I have used ssh-add <private key>, and then it works!

However. Once in a while I have to repeat the ssh-add step because it seems like the key has gone missing on the same computer. This is very annoying, and it seems to happen at random.

Is this a known issue? How do I solve it?

I am using Fedora 17, Zsh and SSH version OpenSSH_5.9p1.

2
  • What happens around the time a key disappears (ie. system update, code deployment, application crash, &tc)? When you say a key is missing, is it not being displayed with ssh-add -l? Could be a permission issue on the parent directory. Aug 15, 2012 at 22:14
  • @emcconville It happens upon rebooting. But perhaps that's how it is supposed to work? Is there any way I can add the key permanently?
    – whirlwin
    Aug 16, 2012 at 10:22

1 Answer 1

1

Check .zshenv

Some flavors of Zsh issue ssh-agent -k command, followed by ssh-add in ~/.zshenv. This will clear out any previous stored ssh keys, and load your user's default keys. You might just need to add the following line to ~/.zshenv

tty -s && ssh-add

Permanently add key for a user

ssh-add will scan for keys in your ~/.ssh directory. Ensure that the dierctory has 700 permissions. The ssh-add command will check & load the following keys

~/.ssh/id_rsa
~/.ssh/id_dsa
~/.ssh/id_ecdsa
~/.ssh/identity

If you want to add your customer EC2 key at login, you can append ssh-add <yourkey> command to ~/.zshenv (like above), or add a record to ~/.ssh/config. Some good examples here.

Host your.ec2.domain.amazon.com
 IdenitityFile ~/path/to/your/custome/key
1
  • Just adding the entry to ~/.ssh/config worked flawlessly!
    – whirlwin
    Aug 16, 2012 at 18:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .