似乎id_dsa
不存在并且它尝试过id_ecdsa
,但它就在那里,我尝试重新生成它几次但仍然不起作用。有人有同样的问题并解决了吗?或者有人知道如何处理吗?
hadoop@i5:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/opt/hadoop/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /opt/hadoop/.ssh/id_dsa.
Your public key has been saved in /opt/hadoop/.ssh/id_dsa.pub.
The key fingerprint is:
2f:ea:1d:fa:eb:3b:86:ac:5f:32:0e:10:e1:09:c5:82 hadoop@i5
The key's randomart image is:
+--[ DSA 1024]----+
|ooo |
|Eo.o |
| .+ |
| . |
| . S |
| . . |
| ..o.+ . |
| ooBoo |
| .+*+*+ |
+-----------------+
hadoop@i5:~$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
hadoop@i5:~$ ssh localhost -v
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /opt/hadoop/.ssh/id_rsa type -1
debug1: identity file /opt/hadoop/.ssh/id_rsa-cert type -1
debug1: identity file /opt/hadoop/.ssh/id_dsa type 2
debug1: identity file /opt/hadoop/.ssh/id_dsa-cert type -1
debug1: identity file /opt/hadoop/.ssh/id_ecdsa type -1
debug1: identity file /opt/hadoop/.ssh/id_ecdsa-cert type -1
debug1: identity file /opt/hadoop/.ssh/id_ed25519 type -1
debug1: identity file /opt/hadoop/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.7
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.7 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA a5:59:74:76:e5:37:42:3a:3b:57:50:be:a6:69:57:63
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /opt/hadoop/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /opt/hadoop/.ssh/id_rsa
debug1: Offering DSA public key: /opt/hadoop/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /opt/hadoop/.ssh/id_ecdsa
debug1: Trying private key: /opt/hadoop/.ssh/id_ed25519
debug1: Next authentication method: password
hadoop@localhost's password:
答案1
要创建无密码的 ssh 连接,首先,您需要创建一个密钥对(PuTTygen 是一个很好的工具)。
生成密钥。将公钥和私钥保存在计算机上的某个位置。在服务器上的 $HOME 目录下,使用mkdir .ssh
命令创建一个名为 .ssh 的目录。然后,通过命令创建一个名为“authorized_keys”的文件vi .ssh/authorized_keys
。将公钥复制并粘贴到此文件中(在 vi 中,i
进入插入模式,ESC
返回命令模式,然后:wq
写入并退出)。接下来,使用chmod 700 .ssh/
并退出服务器调整您的权限。最后,在 PuTTY 上,单击左侧的“连接”以展开树。接下来,单击 SSH,然后单击 AUTH。有一个字段显示“用于身份验证的私钥文件”。导航到您保存私钥的目录,然后使用此文件。
下次登录应该无需密码即可登录。
对于窗户: http://www.howtoing.com/ssh-passwordless-login-with-putty/
对于Linux: http://www.howtoing.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/
编辑 - 根据下面的评论看起来像是权限问题。