bahdimoukhadra
bahdimoukhadra

Reputation: 1

ssh-agent only saving identity for current session

I am having a problem with ssh-agent: when I add my private key to the agent (started with eval "$(ssh-agent -s)", added with ssh-add ~/.ssh/privatekey and checked it was added with ssh-add -l). It works fine for that session, but when I exit and ssh back into the server and starting the agent, I get:

$ ssh-add -l
The agent has no identities.

I used the workaround of adding eval "$(ssh-agent -s) & ssh-add ~/.ssh/privatekey to my .zshrc, it works of course, but there must be another solution? Thanks for any help :)

Upvotes: 0

Views: 197

Answers (1)

Curtis G.
Curtis G.

Reputation: 73

On macOS, you can use the UseKeychain ssh config property to have the passphrase automatically stored in your macOS keychain. For more details, see man ssh_config (which also includes some other useful information).

Different question, but as I understand, macOS automatically starts an ssh-agent. So I don't think that the eval $(ssh-agent -s) business is even necessary.

Using bash and the config properties below, the agent works pretty seamlessly for me without adding the ssh-agent and ssh-add stuff to my .bash_profile. My understanding of it is, however, pretty superficial.

Host *
  UseKeyChain yes
  AddKeysToAgent yes

Upvotes: 0

Related Questions