linux – 禁用SSH的密码登录与删除所有用户的密码相同吗?
发布时间:2020-12-13 18:02:05 所属栏目:Linux 来源:网络整理
导读:我有一个只有root用户的云服务器.我只使用RSA密钥连接到它.为了使其更安全,我想禁用密码功能.我知道这可以通过编辑/ etc / ssh / sshd_config文件并将PermitRootLogin更改为PermitRootLogin而不使用密码来完成.我想知道如果简单地通过passwd -d root删除root
我有一个只有root用户的云服务器.我只使用RSA密钥连接到它.为了使其更安全,我想禁用密码功能.我知道这可以通过编辑/ etc / ssh / sshd_config文件并将PermitRootLogin更改为PermitRootLogin而不使用密码来完成.我想知道如果简单地通过passwd -d root删除root密码将是等效的(假设我没有创建更多用户或新用户也删除了他们的密码).一种方法与另一种方法有任何安全问题吗?
解决方法
使用公钥身份验证会绕过其他身份验证方法,因此不需要
要使用PermitRootLogin而不使用密码,如果有人试图以root用户身份登录并且不强制提供公钥,则会很危险. 要完成所需的操作,请在sshd中禁用密码身份验证,在sshd_config中使用PasswordAuthentication no. 此设置不会影响存储用户密码的/ etc / shadow的内容.如果另一个应用程序想要通过密码进行身份验证(例如CUPS),这仍然有效. 如果要禁用此功能,则使用上述命令删除用户密码将不起作用.它允许给定用户的无密码登录,这绝对不会增加安全性. 发出passwd -l< user>将完成你的意图.请记住,除了ssh之外的其他应用程序可能会遇到问题,因为他们希望在默认设置中使用密码身份验证(sudo,su,CUPS等) 引自man passwd: -l,--lock Lock the password of the named account. This option disables a password by changing it to a value which matches no possible encrypted value (it adds a ′!′ at the beginning of the password). Note that this does not disable the account. The user may still be able to login using another authentication token (e.g. an SSH key). To disable the account,administrators should use usermod --expiredate 1 (this set the account's expire date to Jan 2,1970). Users with a locked password are not allowed to change their password. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |