以下是来自客户:
ssh -p 2xxx -vvv -i /home/jxxxxx/.ssh/authorized_keys ixxxxx.com
以下是调试信息(-vvv)的相关部分:
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/jxxxxx/.ssh/authorized_keys (0x7ff95d1456b0), explicit
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/jxxxxx/.ssh/authorized_keys
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
以下是来自 /var/log/auth.log 的信息服务器:
Aug 9 09:11:00 ixxxxx sshd[8200]: Connection closed by xxx.xxx.xxx.xxx(CLIENT ip) [preauth]
以下是服务器:
/home/jxxxxx 755
/home/jxxxxx/.ssh 700
/home/jxxxxx/.ssh/id_dsa and id_rsa 600
以下是客户:
/home/jxxxxx 755
/home/jxxxxx/.ssh 700
/home/jxxxxx/.ssh/authorized_keys 600 (contains id_dsa.pub and id_rsa.pub)
/etc/ssh/sshd_config 的相关部分(服务器和客户端)
Port 2xxx
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
LoginGraceTime 120
PermitRootLogin no
AllowUsers jxxxxx
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
ChallengeResponseAuthentication no
UsePAM yes
有什么建议吗?这是我在 StackExchange 上的第一个查询,所以这对我来说真是一个难题。关于这个主题的其他 askubuntu 问题/答案都没有起到作用。
答案1
您的私钥必须位于客户相应的公钥必须添加authorized_keys
到服务器。
如果您的私钥名为 或${HOME}/.ssh/id_dsa
,则${HOME}/.ssh/id_rsa
无需选择-i
,ssh
因为它会自动尝试这些默认密钥名称(尽管如果您想明确说明将使用默认私钥,这也不会有什么坏处)。