8

Let's say that my username is user and my computer name is cmp. I notice they are also part of my SSH public key:

user@cmp:~/.ssh$ ls
config  id_rsa  id_rsa.pub  known_hosts
user@cmp:~/.ssh$ cat id_rsa.pub 
ssh-rsa AAAAB3Nzayc2EAABIwAAAQEA4kk3Guk5TwW+MihnO8XjhRLTY11rICPl5iIqlIHWcyuqYyFd
oU4i/VHbJEBiti0fgBztSyZnrW45MyBRG5RU/AFsVuqiRNjyRB59zsLu/J3Uc+fqvy5qNTAAlcMprFnR
N8M6PYl6Tp5gXncbuQaFJmuCgllTcrBrVX0Mep9UvRf5GrZBGprFrY4R/LjH1SFpkQTHFHMI8wMKlsPk
JGJCW9+a/8zmqOrpoE9XRRCfunnROcSq+2MCTRWl7iiligkcdKOq+cbqBNTYV0/6rfyZexArHwh5TeaQ
VdduU0ESN3WVl5i6OwAx2AMz922zZZ/jKWA== user@cmp

What is the purpose of that information?

1 Answer 1

14

It is just a comment. SSH does not use that information at all, and you can change it to anything you want.

If you have more than one key, you need to have some way to know what they are.

Like you, I only have one key because I find it is simpler that way.

I have put several keys into the ~/.ssh/authorized_keys file for certain accounts that several people need to share. Each key goes on its own line and each person gets their own key which is added to that file, so any of them may log on, and they are all authorized. Having that comment at the end makes it clear which key goes with which person.

4
  • Thanks, very informative answer. I've read about the from statement which may restrict from which host a user may log on using his key. I guess == marks the end of the actual key and ssh-rsa is just a description of the hash algorithm that was used.
    – Deleted
    Jul 30, 2009 at 0:34
  • 1
    Kent: The == is Base64 padding, to make the encoded output length a multiple of 4 (bytes). And yes, ssh-rsa is used to tell the algorithm used, but RSA is an asymmetric encryption algorithm - not hashing. (The other one is DSA, with keys tagged ssh-dss.) Jul 30, 2009 at 9:19
  • Is it that the ~/.ssh/authorized_keys file is the same as the ~/.ssh/id_rsa.pub file ? They are just the same public keys files ?
    – Stephane
    Dec 19, 2018 at 16:32
  • 1
    @Stephane No, even though they may be the same sometimes, they are different. ~/.ssh/authorized_keys is a list of keys (one key per line) which can be used to log in. id_rsa.pub is the public half of your own SSH key. If you authorize only your own key, then both files would be the same. Dec 19, 2018 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .