Abram
Abram

Reputation: 41944

SSH key will not permanently add to my keychain

I have tried the following:

ssh-add -K ~/.ssh/id_rsa

This seems to work until I end my terminal session, but then I get prompted for my passphrase again with a new session.

Here is what I see after running the command above:

Identity added: /Users/xxx/.ssh/id_rsa (/Users/xxx/.ssh/id_rsa)

I am on iTerm2 Build 3.0.13 with zsh: stable 5.3.1 running on macOS Sierra 10.12.2

Upvotes: 10

Views: 5905

Answers (2)

Sajib Khan
Sajib Khan

Reputation: 24184

One solution is to add the command in ~/.profile or ~/.bashrc file. Then every time you open a new terminal the command will be executed automatically.
Since you are using zsh you need to add the command in ~/.zprofile or ~/.zshrc file.

ssh-add -K ~/.ssh/id_rsa &> /dev/null

The &> /dev/null is to avoid seeing the Identity added message everytime you open a new terminal window.

Upvotes: 11

Nick Christiny
Nick Christiny

Reputation: 102

Can try ssh-add -K again or edit your ~/.ssh/config to enable the option:

Host * UseKeychain yes

If ssh-add states could not connect, try setting it up with:

eval $(ssh-agent)

Similar to: https://superuser.com/a/1158050

Upvotes: 5

Related Questions