我有一个不受密码保护的ssh 密钥,我用它来连接服务器。现在我想向密钥添加一个密码,所以我已经完成了:
ssh-keygen -p
Run Code Online (Sandbox Code Playgroud)
并添加了一个新的密码:
Enter file in which the key is (/home/user/.ssh/id_rsa):
Enter old passphrase:
Key has comment '/home/user/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
Run Code Online (Sandbox Code Playgroud)
然后,我尝试再次连接到服务器:
ssh user@server.com -v
Run Code Online (Sandbox Code Playgroud)
但我仍然在未输入密码的情况下登录:
debug1:可以继续的身份验证:publickey
debug1:下一个身份验证方法:publickey
debug1:提供RSA公钥:/home/user/.ssh/id_rsa
debug1:服务器接受密钥:pkalg ssh-rsa blen 279
debug1:身份验证成功(公钥)。
已通过 server.com ([xxx.xx.xxx.xx]:22) 验证。
为什么我没有被要求输入密码?
编辑:
Seahorse为我存储了密钥,所以这就是问题所在。
ssh-agent将加密密钥存储在内存中,因此更改磁盘上的物理密钥不会影响其功能。
如果您想确保更改有效,请从代理中删除密钥,然后按照注释中的说明再次添加它(从默认位置ssh-add -D删除并ssh-add再次添加密钥)。