Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 650
Abram Avatar asked Jan 11 '17 20:01

Abram


1 Answers

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.

like image 163
Sajib Khan Avatar answered Dec 30 '22 23:12

Sajib Khan