Permanently Add SSH key ssh-add

Recently on my Mac I wanted to add a second SSH key to my authentication agent. Using the ssh-add command I was able to do just that until I restarted my computer. To add the key each time I start up a new terminal session I just added

ssh-add ~/.ssh/ec2.pem > /dev/null 2>&1

to my .profile file located at ~/.profile

The last part of the command is to route the output of the command to dev null so I don’t see it when I open up terminal.

 > /dev/null 2>&1

Published by


I am a Geek! I hope you enjoyed this recent post.

3 thoughts on “Permanently Add SSH key ssh-add”

  1. Sorry, I misspelled the command in the first post.. that one is right:

    You can add the keys (and their passphrases) to your keychain with the command

    ssh-add -K /path/to/your/keyfile/key

    The -K attribute adds your key permanently to the keychain and they are available after reboot. This is better for keys with passphrases, because you don’t have to enter the passphrases everytime you start a new terminal session. (I tested with osx 10.9.1)

Comments are closed.