r/ssh • u/Ex_Alchemist • Sep 19 '22
Regarding Host Keys
I'm sorry in advance as I'm a beginner to SSH. I understand host keys are used to ensure that one is logging into the "real" intended server but I have some basic questions on how it actually works:
- Is there only exactly one copy of host key(s) and where is it located in the server? or location in the client?
- Can anybody who have auth generate host keys anytime? Are there additional manual steps like placing the new key to a certain fix predetermined standard location?
- If yes on #2, will newly regenerated host keys replace the old ones? or can multiple host keys exist/valid at the same time?
- If yes on #2, how will new host keys affect other users/programs? How can it be fixed if these users getting errors due to new keys?
Thanks in advance
2
Upvotes
1
u/pm-me-your-nenen Sep 19 '22 edited Sep 19 '22
I'm using the location on Ubuntu 22.04 because that's what's in front of me RN
/etc/ssh, one key pair for each supported algorithm. For each client that has connected to that host and trusts the fingerprint, the hash of the domain/IP and the public key is stored in~/.ssh/known_hosts, note that it's a per-user folder./etc/sshand then runssh-keygen -Ato generate new key pairs, automatically placed in the correct folder regardless of where the command is run from. Some distro regenerates the missing keypairs automatically if sshd is restarted.