Ars*_*nes 8 security linux ubuntu ssh rsa
我有一个只有 root 用户的云服务器。我仅使用 RSA 密钥通过 SSH 连接到它。为了使它更安全,我想禁用密码功能。我知道这可以通过编辑/etc/ssh/sshd_config文件并更改PermitRootLogin yes为PermitRootLogin without-password. 我想知道是否简单地删除 root 密码 viapasswd -d root将是等效的(假设我没有创建更多用户或新用户也删除了他们的密码)。一种方法与另一种方法相比是否存在任何安全问题?
fue*_*ero 11
使用公钥身份验证绕过其他身份验证方法,因此没有必要使用PermitRootLogin without-password,如果有人尝试以 root 身份登录并且没有被迫提供公钥,这是很危险的。
要完成您想要的操作,请在 sshd 中禁用密码身份验证,请PasswordAuthentication no在您的sshd_config.
此设置不会影响/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.
Run Code Online (Sandbox Code Playgroud)