sudo -i
并且su
不能以 root 身份工作。
[atguigu@hadoop103 ~]$ sudo -i
[atguigu@hadoop103 ~]$ su
Password:
ssh
以 root 身份登录并立即关闭。
[atguigu@hadoop103 ~]$ ssh root@hadoop103
root@hadoop103's password:
Last login: Mon Jan 18 18:37:57 2021
Connection to hadoop103 closed.
但它可以su
或ssh
作为其他用户。
[atguigu@hadoop103 ~]$ ssh atguigu@hadoop103
Last login: Mon Jan 18 17:38:44 2021 from xxx
su
其他用户。
[atguigu@hadoop103 ~]$ su atguigu
Password:
[atguigu@hadoop103 ~]$ exit
exit
[atguigu@hadoop103 ~]$
我的/etc/sudoers
有root。它喜欢。
root ALL=(ALL) ALL
atguigu ALL=(ALL) NOPASSWD:ALL
/etc/passwd
有根字段喜欢
[~]$ cat /etc/passwd | grep root
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
ps:我的环境是CentOS7。
您/etc/passwd
指定/bin/bash
为 root 的命令解释器。如果是/sbin/nologin
或/bin/false/
,症状将是相同的。然而事实并非如此。
运行sudo /bin/bash -x
。你可能会看到+ exit
。包含 root 的 Bash 的启动脚本之一exit
,因此 shell 退出。
sudo /bin/bash --norc
应该跳过这些文件。它应该给你一个提升的外壳。
下一步是找到exit
阻止你正常启动shell的这个;并将其删除。它可能在.bashrc
root 用户的主目录中(你/etc/passwd
说主目录是/root
,所以编辑/root/.bashrc
)。还有,/etc/bash.bashrc
但exit
会影响所有用户,所以我们可以排除它。
请注意,如果您不是唯一的管理员,那么它可能是故意放置exit
在 root 中的另一个管理员,.bashrc
以防止用户使用 root 的 shell。有了sudo
访问权限,您就可以恢复这一点,但请确保您不会干扰其他人对事情应该如何运作的总体看法。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句