我正在尝试使用公钥身份验证通过 SSH 连接到我的 ubuntu 服务器。由于某些原因,我收到“权限被拒绝(公钥)”。在客户端,每当我执行
ssh -i ~/.ssh/id_rsa <username>@<ip> -p <port>
.
我服务器上的 auth.log 有以下输出:
sshd[1425]: Connection closed by <client-ip> [preauth]
但是,一旦我使用相同的用户名在我的服务器上实际登录,来自我的客户端的以下 ssh 连接就会成功。但是,一旦我以物理方式注销,来自客户端的下一个 ssh 会话就会失败。
/etc/ssh/sshd_config
# What ports, IPs and protocols we listen for
Port <port>
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 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
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# …
Run Code Online (Sandbox Code Playgroud)