Where Are SSH Keys and Config Stored?
SSH keys live in ~/.ssh per user, daemon config in /etc/ssh. Back up keys, never share private ones.
Last updated
SSH splits trust by side. Your keys live in ~/.ssh: private keys that prove you, public keys you install elsewhere, known_hosts pinning servers you visited. The daemon answers from /etc/ssh.
Permissions are load-bearing. Private keys must read 600 or ssh refuses them. Copy with permissions preserved or plan a chmod pass after every move.
Where OpenSSH stores this, by platform
~/.ssh
Private keys, public keys, authorized_keys, known_hosts, config. Per-user folder, 700 perms. This is the backup.
/etc/ssh/sshd_config
sshd_config plus host keys. System-wide, needs sudo. Same split on macOS with its own defaults.
~/.ssh
Same per-user layout as Linux. Daemon config differs since macOS manages sshd through its own sharing prefs.
%USERPROFILE%\.ssh
Keys live wherever the client stores them, commonly %USERPROFILE%\.ssh. Daemon side does not apply on desktop Windows.
Frequently asked questions
How do I move SSH keys to a new machine?
Copy the whole ~/.ssh folder preserving permissions: 700 on the dir, 600 on private keys. Regenerate host prompts resolve themselves on first connect.
Where is the SSH server config?
Edit /etc/ssh/sshd_config and restart sshd. User keys in authorized_keys stay valid. Test in a second session before closing the first.
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED. Fix?
Remove that host line from ~/.ssh/known_hosts. Reconnect and verify the new fingerprint out of band before accepting.
Notice an outdated path? Let us know.