0

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
Viren
  • 5,812
  • 6
  • 45
  • 98
  • Possible duplicate of [SVN+SSH, not having to do ssh-add every time? (Mac OS)](https://stackoverflow.com/questions/1909651/svnssh-not-having-to-do-ssh-add-every-time-mac-os) – Jakub Kukul Jun 24 '18 at 14:23

1 Answers1

2

You need to store the passphrase in you keychain.

Try:

ssh-add -K private-key

Hope this helps.

Harshniket Seta
  • 654
  • 7
  • 7
  • Using the MacOS Monterrey you'll probably get this warning message: `WARNING: The -K and -A flags are deprecated and have been replaced by the --apple-use-keychain and --apple-load-keychain flags, respectively. ` So you can also use `ssh-add --apple-use-keychain private-key` – gabrielpedepera Sep 29 '22 at 12:44