14

When I create an ssh key with ssh-keygen, it includes the username and hostname of the machine it was created on. Is there any way to avoid this? I read the manpage and didn't see anything.

20

The user name is a comment, you can delete it or set it with the -C option

I do not see a host name anywhere in the keys, what file are you looking at ?

ssh-keygen -f test -C noname

Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in test.
Your public key has been saved in test.pub.
The key fingerprint is:
a8:fa:78:ea:bb:c6:70:67:4c:79:ac:0d:a7:78:5a:40 noname
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|  E              |
| .   o           |
|  . + +.         |
|   = B. S        |
|. o O..          |
| + *.            |
|  +o.            |
| oB*.            |
+-----------------+

cat test
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,6BD3B77199F57BCD0BBC4BD4D717931C  

+hko6XxmbmqLlV32dFLTuS6vYSh5OGOBR9Q29OVewRwS6XN2+jbuCBviOdN/CnLh
k/Dzpjt9bPinFLI73RsfYMGUZ+kiBKIotYBqjJrkfMLNkZV0xvzk//tIEQatKyYI
W3OczGVt4EXfXozTvAQSpbEA5pYS5nLCbWSwx98Ilsqej+bnHJDflAhY5kFnrvOm
N66ODWa8FXpmJmJnIU4E8X+w33NO0nxXEiK8EUoRKFHnopwE+uQVkC6z3gPzqCd0
gCJrCDZ7zBaz947jlebH91liygrj1wTnuUbJOk0VnHyHMO1nO0piPOmjPZbL/C4Q
R8Z7C2Hm4cCaTRYbzZCcLvXCdlisCnGmM2a6dIGU5JECYuCB14k0npYqlY0dSJfb
XJx07z0wlkBWzOOUrWkc4U21+BBmYZe8DgHX/p6TNPxkugumIEUgu+xSL8RhwM6Y
lF4miW1s30g4/BpzN5GHTrpJGyyDBLojGR+P42LmsfiuCojU0NFbmrNlX23dSGj0
3wTSwuw179P6FDAEhJo8Znly8W+XP1pKeRn/ozdXW3WJWICDFZzVIe6VSlRES95Q
tcSeWDQRKhZWsGR+yriRwQSYROVje60d1TTMDI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MNdzL7zCRvijpd4PaEbK4/zcXb6ns/9Eg2URJEVIDEBbKFrNnCQU48VNjiGG4yDyrn7COHLzWKgvLjraYV8gD0MnzqE52U5L85iuuhXcgVhc0i4Jqu3k4XoUNHGqtYMZstBhS39MCD2h8bkfKuz4eycWlyfKpktd8yIJjeUsV39mw7U7/qh/508RGuwriYe8AYNqgivnL0PmZaDwZGTCnEFaP0IPLbqKyFTcmSuVChmTYttE1Kcj4DNI57APaq2EzSGUNrBVGSJ7Q6KbXC4xiSF+RCDy8ruOk7hj2x2MGOwBZdvhy55kmMkhUMCC7BUcSiRA9F noname

No username or hostname in either file, test or test.pub

  • The comment was being set to my username@host. I didn't realize that that was the "comment". Thanks! – Davis Yoshida Nov 16 '14 at 6:16
  • OK, ~/.ssh/known_hosts does track hostname and ip (of the server) as it should, which is why I asked – Panther Nov 16 '14 at 7:06
  • 1
    I would prefer to use ssh-keygen -f amp_generic.pem -C "" so that I do not have any name in the SSH public file – vikas027 Apr 26 '17 at 12:35

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.