← All guides

Where to store SSH keys on a Mac

9 November 2026

There are four sensible places for an SSH key on a Mac. ~/.ssh with a passphrase is the default and works everywhere. Adding the macOS Keychain saves you typing that passphrase. The Secure Enclave (with Secretive) keeps the key in hardware where it can’t be copied. An encrypted vault with an SSH agent (Fydra, 1Password) keeps the key off disk and asks for Touch ID before each use. Which one fits depends on what you want to protect against.

I make Fydra, one of the options here. I’ve tried to be fair to the others.

The default: a file in ~/.ssh

ssh-keygen -t ed25519 writes two files:

~/.ssh/id_ed25519       # private key: never share this
~/.ssh/id_ed25519.pub   # public key: goes on GitHub, servers, etc.

The private key file is readable only by you (chmod 600), and SSH refuses to use it if other users can read it. If you set a passphrase, the file is encrypted with it.

What it protects against: another user on the Mac, and with a passphrase, someone who copies the file. What it doesn’t: any app or script running as you can read the file. If the key has no passphrase, a single malicious npm install or VS Code extension can copy it. Without a passphrase, a backup or a synced folder holding ~/.ssh is the key in plain text.

Rule of thumb: a key file in ~/.ssh should always have a passphrase.

Add the macOS Keychain, so you don’t type the passphrase

Typing a passphrase for every git push gets old. macOS’s own ssh can keep the passphrase in your login Keychain. Add this to ~/.ssh/config:

Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_ed25519

and load the key once:

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

From then on, the passphrase comes from the Keychain and the key is loaded into the built-in agent when you first use it.

What changes: the key is still a file in ~/.ssh, encrypted with a passphrase that’s now unlocked whenever you’re logged in. Convenient, and much better than no passphrase. But the agent signs for any process that asks, with no prompt, and UseKeychain is an Apple addition: it works with the ssh in /usr/bin, not with OpenSSH from Homebrew.

The Secure Enclave, with Secretive

Macs with Apple silicon or a T2 chip have a Secure Enclave, a separate processor that can create keys and sign with them without the key ever leaving the chip. Secretive, a free open source app, turns that into an SSH agent: it creates a key in the Secure Enclave and asks for Touch ID (or your Apple Watch) when SSH uses it.

What it protects against: almost everything. The private key can’t be read by any software, including malware running as you or as root. The tradeoff: the key can’t be exported, backed up or synced. Each Mac gets its own key, so you add a new public key to GitHub and every server for each Mac, and when a Mac dies, its key is gone. Secure Enclave keys are ECDSA (P-256), which nearly every service accepts. You can’t bring your existing Ed25519 or RSA keys. How it compares with a synced vault: Secretive vs 1Password vs Fydra.

An encrypted vault with a Touch ID agent

The fourth option keeps your existing keys, encrypted, in a password vault, and an SSH agent from the same app signs with them after you approve with Touch ID. 1Password and Fydra both work this way on a Mac.

What it protects against: key files lying around on disk, and silent use by other processes, because each new app has to be approved. The tradeoff: the key exists in software, so it’s only as safe as the vault and the Mac it runs on. It’s not as strict as the Secure Enclave, but you keep one key across Macs, and it comes back with the vault if a Mac dies.

In Fydra, it looks like this:

  1. In Fydra for Mac, click +, choose SSH Key, then Import Existing Key and paste the private key (or Generate New Key for a new Ed25519 or RSA key).
  2. Install the free Fydra SSH Agent and point SSH_AUTH_SOCK at it.
  3. Run ssh-add -l to check that the key is listed, then delete the old file from ~/.ssh.

Keys are encrypted with AES-256-GCM before they’re stored and sync through your own iCloud, so the same key works on your other Macs. The full setup, with screenshots, is in how to use Touch ID for SSH keys on a Mac.

Side by side

~/.ssh + passphrase + Keychain (UseKeychain) Secure Enclave (Secretive) Vault + agent (Fydra)
Key on disk Encrypted file Encrypted file Never Never unencrypted
Prompt before use Passphrase, once per load None Touch ID or Watch Touch ID, remembered as you choose
Keep existing keys Yes Yes No Yes, Ed25519 and RSA
Same key on several Macs By copying the file By copying the file No Yes, via iCloud
Survives a lost Mac If backed up If backed up No Yes
Cost Free Free Free Fydra Pro

Which should you use?

  • A single personal Mac, a few servers: ~/.ssh with a passphrase and UseKeychain is fine. Just never leave a key without a passphrase.
  • You want hardware-level protection and can live with one key per Mac: Secretive.
  • Several Macs, keys you already use everywhere, and a Touch ID prompt before use: a vault with an agent, such as Fydra or 1Password. If you’re weighing those, see 1Password SSH agent alternatives.

Whatever you choose, keep the public keys (*.pub) where your tools expect them, and remove old private key files once the new setup works. If a key was ever stored without a passphrase in a synced folder or a backup, generate a new one and replace it on your servers.

Frequently asked questions

Where are SSH keys stored on a Mac by default?

In the .ssh folder in your home folder: ~/.ssh/id_ed25519 for the private key and ~/.ssh/id_ed25519.pub for the public key. ssh-keygen creates them there unless you choose another path.

Does the macOS Keychain store my SSH key?

It stores the key's passphrase, not the key. With UseKeychain yes in ~/.ssh/config, or ssh-add --apple-use-keychain, macOS saves the passphrase in your login Keychain so you don't type it again. The private key stays in ~/.ssh.

Should my SSH key have a passphrase?

Yes, if the key is a file in ~/.ssh. Without one, anyone or anything that can read the file can use the key. If the key lives in an encrypted vault or the Secure Enclave instead, the vault or chip protects it.

Can I sync SSH keys between Macs?

iCloud does not sync ~/.ssh, and Secure Enclave keys cannot leave their Mac by design. Copying the key file by hand works but leaves copies around. A vault that syncs through your iCloud, such as Fydra, keeps one key on every Mac.

Is it safe to keep SSH keys in iCloud Drive?

Not as plain files. A key in iCloud Drive is on every device and in your iCloud backup, and it is only as safe as that folder. If you must, keep a strong passphrase on it; an encrypted vault is better.