Adding an SSH Key to Keychain on macOS
Store your SSH key in the macOS keychain so you can authenticate without entering your passphrase each time.
Adding an SSH Key to Keychain on macOS
Why Add an SSH Key to Keychain?
Storing your SSH key in the macOS keychain allows you to use SSH without entering your passphrase every time, making authentication seamless.
Steps to Add SSH Key to Keychain
- Ensure SSH Key Exists If you haven’t generated an SSH key, create one with:
1
ssh-keygen -t ed25519 -C "your_email@example.com"
- Add Your SSH Key to Keychain Run the following command to store your private key in the macOS keychain:
1
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
Replace
id_ed25519
with your key filename if different. - Ensure SSH Config Includes Keychain Option Add this to your SSH config (
~/.ssh/config
):1 2 3 4
Host * UseKeychain yes AddKeysToAgent yes IdentityFile ~/.ssh/id_ed25519
That’s it! Your SSH key is now stored in the keychain and will be used automatically when needed.
☕ Support My Work
If you found this post helpful and want to support more content like this, you can buy me a coffee!
Your support helps me continue creating useful articles and tips for fellow developers. Thank you! 🙏
This post is licensed under CC BY 4.0 by the author.