我开始进行无密码 SSH 会话。现在我可以像这样连接到我的服务器:
bash-3.2$ ./dev2
Enter passphrase for key '/Users/roger/.ssh/id_rsa':
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 2.6.32-042stab120.11 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
0 packages can be updated.
0 updates are security updates.
Last login: Wed Aug 23 08:25:06 2017 from 176.59.142.224
现在我编辑 sshd_config 并在末尾添加以下内容:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
重新启动服务器但 ssh 仍然要求我输入密码。
我应该怎么办?
答案1
pass phrase
在这种情况下,您在创建时已经拥有密码,因此如果您在未使用pass phrase
SSH 连接的情况下连接,则应使用以下命令创建新密钥:
**[test@test test]$ ssh-keygen**
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):
Created directory '/home/test/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:
ac:5e:9a:72:c6:cd:82:9c:cd:1f:bc:4d:de:f9:50:d9 tanto@hlink_backup_086
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| |
| . o |
| S o E|
| o . |
| . *.o+ . . |
| =.B+o* . o |
| ++oo o o.. |
+-----------------+
在步骤中Enter passphrase,
你应该输入空。创建后,你可以将密钥添加到远程服务器的id_rsa.pub
文件夹中,然后检查权限并使用 chmod 600 更改文件 authorized_keys:.ssh/authorized_keys
[root@test test]# chmod -R 600 /home/test/.ssh/authorized_keys
[root@test test]# ls -l /home/test/.ssh/authorized_keys
-rw------- 1 test test 1212 Jul 12 14:17 /home/test/.ssh/authorized_keys