1

Usually, at the end of an RSA public key, you find something like 'username@hostname' by default or something else otherwise you specified. It is said that it is just a comment and doesn't matter at all.

My question is the following. When I copy and add my public key to a server's authorized_keys file, is it necessary to include this part together with the long key string? Or should this part match at all between the server and my local machine?

xiaohuamao
  • 107
  • 6

1 Answers1

0

I assume that by "send" you mean adding your public key to your account's authorized_keys file.

When adding the key there, it usually makes little sense to use username@hostname, as it's clear for what username and host the key is being used.

You better use a more meaningful comment, explaining uses of the key (if you use more keys). If you have just one key, no comment is needed.

Martin Prikryl
  • 21,071
  • 9
  • 77
  • 157
  • I don't know about the official practice, but the username@host can be a hint of where the key pair is generated (the default behaivor of ssh-keygen). Therefore, it can somehow show who (which source) is accessing that "clear" username and host on the destination machine. – Ali Asgari Aug 28 '23 at 20:04