Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何防止ssh keygen在公钥中使用我的登录名和计算机名?_Ssh_Customization - Fatal编程技术网

如何防止ssh keygen在公钥中使用我的登录名和计算机名?

如何防止ssh keygen在公钥中使用我的登录名和计算机名?,ssh,customization,Ssh,Customization,我在OSX上运行了ssh-keygen,当我显示生成的公钥时,我看到我的登录名和机器名出现在密钥的最后一部分。有没有办法让它使用不同的值或根本不使用它?是的!根本不需要它,它只是随意添加的,让你很容易记住它来自哪里。如果要编辑它,只需打开终端会话并键入: $ nano ~/.ssh/id_rsa.pub 从手册页“ssh keygen(1)”中删除行的结尾部分(在双等号之后)。: 对于RSA1密钥,密钥文件中还有一个注释字段,仅用于 方便用户识别钥匙。评论可以告诉我们 关键是,或任何有用的。注

我在OSX上运行了
ssh-keygen
,当我显示生成的公钥时,我看到我的登录名和机器名出现在密钥的最后一部分。有没有办法让它使用不同的值或根本不使用它?

是的!根本不需要它,它只是随意添加的,让你很容易记住它来自哪里。如果要编辑它,只需打开终端会话并键入:

$ nano ~/.ssh/id_rsa.pub

从手册页“ssh keygen(1)”中删除行的结尾部分(在双等号之后)。

对于RSA1密钥,密钥文件中还有一个注释字段,仅用于 方便用户识别钥匙。评论可以告诉我们 关键是,或任何有用的。注释已初始化为“user@host” 创建密钥时,但可以使用-c选项进行更改。 … -C评论 提供新的注释。 -c请求更改私钥和公钥文件中的注释。这 操作仅支持RSA1密钥。该程序将提示 包含私钥的文件,如果密钥具有 一个,还有新的评论。
因此,在创建密钥时,您可以使用
-C“$desiredcommenttext”
提供您喜欢的任何注释文本;或者对于现有的密钥,使用
-c
选项来更改注释。

与其直接对数据文件进行黑客攻击(该文件可能会更改,因此很脆弱),不如使用官方工具的用户界面来实现此目的。@bignose假设知道正确的命令,不是吗? For RSA1 keys, there is also a comment field in the key file that is only for convenience to the user to help identify the key. The comment can tell what the key is for, or whatever is useful. The comment is initialized to “user@host” when the key is created, but can be changed using the -c option. … -C comment Provides a new comment. -c Requests changing the comment in the private and public key files. This operation is only supported for RSA1 keys. The program will prompt for the file containing the private keys, for the passphrase if the key has one, and for the new comment.