Linux 如何彻底删除root密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11700690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I completely remove root password
提问by Plazgoth
I am running slitaz distro, and would like to completely remove the root password. I have tried giving a blank password to the passwd
command, however that did not seem to do the trick. It gave me an error password was too short, ans it still asked me for a password when I ssh-ed in. The password was just hiting the "Enter" key.
我正在运行slitaz 发行版,并想完全删除root 密码。我曾尝试为该passwd
命令提供一个空白密码,但这似乎并没有奏效。它给了我一个错误密码太短,当我 ssh 进入时它仍然要求我输入密码。密码只是按“Enter”键。
UPDATE:
Perhaps it has to do with the fact that slitaz uses dropbear for ssh? Because even with a blank password for root in /etc/shadow
, it still prompts for a password.
更新:
也许这与slitaz将dropbear用于ssh的事实有关?因为即使 root 中的密码为空/etc/shadow
,它仍然会提示输入密码。
采纳答案by tiwo
Did you try passwd -d root
? Most likely, this will do what you want.
你试了passwd -d root
吗?最有可能的是,这会做你想做的。
You can also manually edit /etc/shadow
: (Create a backup copy. Be sure that you can log even if you mess up, for example from a rescue system.) Search for "root". Typically, the root entry looks similar to
您也可以手动编辑/etc/shadow
:(创建备份副本。即使您搞砸了,例如从救援系统中,请确保您可以登录。)搜索“root”。通常,根条目看起来类似于
root:$X$SK5xfLB1ZW:0:0...
There, delete the second field (everything between the first and second colon):
在那里,删除第二个字段(第一个和第二个冒号之间的所有内容):
root::0:0...
Some systems will make you put an asterisk (*) in the password field instead of blank, where a blank field would allow no password (CentOS 8 for example)
某些系统会让您在密码字段中放置星号 (*) 而不是空白,其中空白字段不允许输入密码(例如 CentOS 8)
root:*:0:0...
Save the file, and try logging in as root. It should skip the password prompt. (Like passwd -d
, this is a "no password" solution. If you are really looking for a "blank password", that is "ask for a password, but accept if the user just presses Enter", look at the manpage of mkpasswd
, and use mkpasswd
to create the second field for the /etc/shadow.)
保存文件,然后尝试以 root 身份登录。它应该跳过密码提示。(例如passwd -d
,这是一个“无密码”解决方案。如果您真的要寻找“空白密码”,即“要求输入密码,但如果用户按 Enter 则接受”,请查看 的联机帮助页mkpasswd
,然后使用mkpasswd
为 /etc/shadow 创建第二个字段。)