Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了linux – 禁用SSH的密码登录与删除所有用户的密码相同吗?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

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

大佬总结

以上是大佬教程为你收集整理的linux – 禁用SSH的密码登录与删除所有用户的密码相同吗?全部内容,希望文章能够帮你解决linux – 禁用SSH的密码登录与删除所有用户的密码相同吗?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。