About

Known Hosts File is a client file that lists all known remote host and is used by the ssh client

Format

hostname algo public_key
hostname,ip algo public_key

where:

Management

Add a host

ssh-keyscan server-ip >> ~/.ssh/known_hosts

Example

192.168.1.20 ecdsa-sha2-nistp256 public_key
gerardnico.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABA............

# Comments allowed at start of line
closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
# A hashed hostname
|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa AAAA1234.....=
# A revoked key
@revoked * ssh-rsa AAAAB5W...
# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...

Location

home\.ssh\known_hosts

Windows

Ie:

  • User: C:\Users\login\.ssh\known_hosts
  • System: C:\Windows\System32\config\systemprofile\.ssh\known_hosts

Linux

  • User scope ~/.ssh/known_hosts
  • System scope /etc/ssh/known_hosts

Implementation

Documentation / Reference