I find the ~/.ssh/known_hosts file a bit hard to read.

It'd help if I could add comments to it so I thought I should ask if that's possible.

  • 2
    What sort of comments are you hoping to add? Each line is prefixed with the host that you connected to (either IP or domain name). What more information could you possibly need? – EEAA Jan 21 '16 at 18:03
  • Well, the host is an IP that's hard to remember, would the entry still work if I edited the prefix to an easier to remember string? – Emanuil Rusev Jan 21 '16 at 18:07
  • No. That file matches IP or hostnames to host keys. If you change it to something else, it's not going to work. Just always connect using a hostname and your problem is solved. – EEAA Jan 21 '16 at 18:08
  • Ok, that's what I'm going to do then, thanks a lot! – Emanuil Rusev Jan 21 '16 at 18:09

Yes. As the manual page for sshd notes:

Each line in these files contains the following fields: markers (optional), hostnames, bits, exponent, modulus, comment. The fields are separated by spaces.

[...] The optional comment field continues to the end of the line, and is not used.

Lines starting with ‘#’ and empty lines are ignored as comments.

This means that you can create comments in two ways:

# Comments allowed at start of line
closenet,..., 1024 37 159...93 closenet.example.net

The whole first line is comment and the closenet.example.net is also comment


not sure if this solves the problem, but you can alias the IP in your .ssh/config file with something like this

Host rememberme

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.