Search code examples
macossshcapistranossh-keysssh-agent

SSH-ADD Key getting Flushed


I recently switch to Mac from an Ubuntu box and I'm facing this odd ssh issue which I'm not able to understand why?

Every time I restart/reboot by Mac by private key which was added ssh lists using ssh-add keep getting flushed

ssh-add -l 
The agent has no identities.

I'm not sure if this is a desired behavior of ssh-add but what I know is I wasn't doing this in my Ubuntu box neither on my earlier Mac machine to the top of it any newly created ssh keys too aren't getting added to the ssh-add list

Now I not sure why the new Mac isn't working like above

Anyway to solve this I have to add my identity every time (manually) like this

ssh-add private-key

Now Can anyone please explain what is the reason for this odd behaviour and feasible solution to solve it

Why I need this is that I have a Capistrano script which

 set :ssh-options,{"forward" => true }

and every time I run the cap script it fail because of the same reason explain above and succeed only when I add the private key to ssh-add using the command mention above

Mac OS in question is

Note: Mac-OS X 10.9.2

Solution

  • You need to store the passphrase in you keychain.

    Try:

    ssh-add -K private-key
    

    Hope this helps.