Linux密钥登录问题

能否对Linux服务器实现这样的登录需求:普通用户可以使用密码验证登录;一个特殊用户必须采用ssh密钥文件进行登录。
我在sshd_config配置文件中发现PasswordAuthentication yesPubkeyAuthentication yes都是针对所有用户的

阅读 4.6k
1 个回答

sshd_config末尾添加:

Match User username
PasswordAuthentication no

注意为什么是在末尾加?是因为 Match语法一直匹配到下一个Match 或者文件末尾
这里面如果有其他配置的话 都只针对此Match生效

如果是针对一个组

Match Group groupname
PasswordAuthentication no

如果是反过来,只有某用户可以使用密码登录,其他用户都不可以

Match User !username
PasswordAuthentication no
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题