有些人习惯走 ssh key 防御 ssh 安全,有些人喜欢走 acl 也就是 ip 白名单,我属于后者。
我有在用 virmach 的 鸡,但是 virmach 太便宜了所以没有 硬 fw ,所以防御只能用 sshd.conf 和 firewalld/iptables …
配置思路:使用 sshd 的 match address 关闭全局的 passwordAuthentication 和 permitRootLogin ,然后再在 ssh 文件配置(末尾)加上【如果需要配置 ip 段,比如 8.8.0.0/16 那么,在下面的配置文件中可以直接写 8.8.?.? 无需掩码】:
# ssh登陆IP白名单
Match Address 127.0.0.1
PermitRootLogin yes
PasswordAuthentication yes