Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  emcconville Aug 15 '12 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 '12 at 10:22

1 Answer 1

up vote 1 down vote accepted

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
share|improve this answer
    
Just adding the entry to ~/.ssh/config worked flawlessly! –  whirlwin Aug 16 '12 at 18:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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