防止ssh-keygen包含用户名和主机名


17

当我使用ssh-keygen创建ssh密钥时,它包括在其上创建计算机的用户名和主机名。有什么办法可以避免这种情况?我读了手册页,什么也没看到。

Answers:


26

用户名是注释,您可以删除它或使用-C选项进行设置

在密钥的任何位置都看不到主机名,您在看什么文件?

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/ozdXW3WJWICDFZzVIe6VSlRES95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zaC1yc2EAAAADAQABAAABAQC2XiZLbaRwCZFPYUMNdzL7zCRvijpd4PaEbK4 / zcXb6ns / 9Eg2URJEVIDEBbKFrNnCQU48VNjiGG4yDyrn7COHLzWKgvLjraYV8gD0MnzqE52U5L85iuuhXcgVhc0i4Jqu3k4XoUNHGqtYMZstBhS39MCD2h8bkfKuz4eycWlyfKpktd8yIJjeUsV39mw7U7 / QH / 508RGuwriYe8AYNqgivnL0PmZaDwZGTCnEFaP0IPLbqKyFTcmSuVChmTYttE1Kcj4DNI57APaq2EzSGUNrBVGSJ7Q6KbXC4xiSF + RCDy8ruOk7hj2x2MGOwBZdvhy55kmMkhUMCC7BUcSiRA9F NONAME

文件,test或test.pub中都没有用户名或主机名


该评论已设置为我的username @ host。我没有意识到那是“评论”。谢谢!
戴维斯·吉田

好吧,〜/ .ssh / known_hosts确实会跟踪(服务器的)主机名和ip,这就是为什么我问
Panther

1
我希望使用它,ssh-keygen -f amp_generic.pem -C ""以便我在SSH公共文件中没有任何名称
vikas027
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.