服务端配置文件(/etc/ssh/sshd_config),注意有没有引入别的config,例如ubuntu的50-cloud-init.conf。
# 允许公钥登录
PubkeyAuthentication yes
# 全局禁用密码登录
PasswordAuthentication no
# 旧版叫ChallengeResponseAuthentication
KbdInteractiveAuthentication no
UsePAM yes
# 特定地址允许密码登录
Match Address 192.168.8.*,127.0.0.1,172.24.*.*
PasswordAuthentication yes
sudo sshd -t
sudo service ssh reload