我可以不使用密码和私钥登录我的 ssh 服务器

我可以不使用密码和私钥登录我的 ssh 服务器

我禁用了 root 登录和密码登录,更改了端口,使用了一段时间的 mosh,但为什么我可以从非 root 用户登录,而无需密码和私钥?

添加了一些信息ssh -v,但我没有添加选项-i ~/ssh_keys/bandwagon_ssh_key

debug1: Server host key: RSA a4:11:29:3a:7a:...
debug1: Host '[104.224...]:28...' is known and matches the RSA host key.
debug1: Found key in ~/.ssh/known_hosts:13
...
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: ~/.ssh/github
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: ~/ssh_keys/bandwagon_ssh_key

答案1

我正在使用 Macbook 登录 ubuntu 服务器。ssh-agent 会记住私钥。

用于ssh-add -l列出密钥,用于ssh-add -d ~/ssh_keys/bandwagon_ssh_key删除密钥。

实际上我移走了~/ssh_keys/bandwagon_ssh_key,所以我习惯ssh-add -D删除所有密钥。

答案2

因为服务器已经知道你的公钥,而你没有为该密钥设置密码。所以它只允许你登录。如果有人在设置后尝试从一台没有上传密钥的机器上登录,它不会让他们连接。

相关内容