Skip to content

Instantly share code, notes, and snippets.

@pbt001
Forked from HansCz/add-ssh-key-to-agent.bash
Created July 10, 2019 10:06
Show Gist options
  • Save pbt001/77f2237a990072cd67dda5515d042c20 to your computer and use it in GitHub Desktop.
Save pbt001/77f2237a990072cd67dda5515d042c20 to your computer and use it in GitHub Desktop.
SSH (Bash) - adding key to ssh-agent
# Linux
eval `ssh-agent`
ssh-add ~/.ssh/some_key_rsa
ssh user@server
# Mac
## As of the Leopard release of OS X, ssh-agent is more tightly integrated with Keychain. It is possible to store the passphrases of all of your SSH keys securely in Keychain, from which ssh-agent will read them on startup. The bottom line is that it is simple to secure your keys with passphrases, but never have to type the passphrase to use them! Here is how:
## Add the pass phrase to each ssh key to keychain:
ssh-add -K [path/to/private SSH key]
## Whenever you reboot your Mac, all the SSH keys in your keychain will be automatically loaded. You should be able to see the keys in the Keychain Access app, as well as from the command line via:
ssh-add -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment