我想确保通过SSH访问计算机的唯一方法是客户端的密钥是否已添加到authorized_keys服务器上的文件中.
为此,我编辑/etc/ssh/sshd_config并启用以下选项
ChallengeResponseAuthentication no
PasswordAuthentication no
PubkeyAuthentication yes
UsePAM no
Run Code Online (Sandbox Code Playgroud)
在此之后,我重新启动sshd服务
sudo /etc/init.d/ssh restart
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试从未将其密钥保存在服务器的授权密钥文件中的客户端ssh到服务器时,系统会提示我输入密码.
编辑:我已经弄清楚问题是什么,但我将在这里留下这个问题,以防它对其他人有用.
当从客户端连接不在authorized_keys文件中的密钥时,服务器会要求输入密码,但无论输入什么密码,都会被拒绝.我认为这样攻击者很难理解sshd的配置方式.
小智 9
我在 ubuntu 20.04 上,发现 sshd_config 在最开始的“Include /etc/ssh/sshd_config.d/*.conf”中包含一个文件,其中包含“PasswordAuthentication yes”,该文件覆盖 sshd_config 中的设置
| 归档时间: |
|
| 查看次数: |
2129 次 |
| 最近记录: |