SSH禁止特定用戶使用密碼登錄可以在/etc/ssh/sshd_config添加Match配置過濾指定的用戶。
按用戶過濾
Match User user1,user2,user3,user4
PasswordAuthentication no
按組過濾
Match Group group1
PasswordAuthentication no
使用嘆號(!)取非過濾
Match User !root
PasswordAuthentication no
注意:Match是引入了一個條件塊,如果滿足Match行指定的條件,那么隨后的指令將會覆蓋全局配置的指令。Match條件塊的結束標識為下一個Match指令或者是文件結束