Match-sshd配置登录策略

Match配置:指定网段必须使用密码登陆

修改配置文件 /etc/ssh/sshd_config

1
2
3
4
5
6
7
8
# 全局设置:强制密钥登录
PasswordAuthentication no
PubkeyAuthentication yes

# 仅针对本机内网IP启用密码登录
Match Address 192.168.1.0/24
    PasswordAuthentication yes
    PubkeyAuthentication no  # 禁止密钥登陆