linux – 禁用SSH的密码登录与删除所有用户的密码相同吗?

我有一个只有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.

相关文章

查找全部容器的日志文件 $ sudo find /var/lib/docker/conta...
Linux日志文件中列属性的详细解析
在Linux系统中没有duf命令,如何有效地管理磁盘空间?
深入探讨EncryptPad在Linux操作系统中的功能和优势
原理和应用场景:Linux中ttyload工具的工作原理和实际用途
深度解析SELinux的三种策略类型