今天没事,做了个小实验,普通用户切换如何省略密码
1、省略密码验证
很简单,只需把/etc/passwd中的root:x:0:0:root:/root:/bin/bash,改为root::0:0:root:/root:/bin/bash,就可以了,就是去掉了里面的x,这样root用户就不用密码了。其他用户也一样。
[root@localhost ~]# useradd user01
[root@localhost ~]# passwd user01
Changing password for user user01.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# useradd user02
[root@localhost ~]# passwd user02
Changing password for user user02.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
创建完用户名密码后,现在切换下用户
[root@localhost ~]# su - user01
[user01@localhost ~]$ whoami
user01
[user01@localhost ~]$ su - user02
口令:
[user02@localhost ~]$
输入用户口令后,才能切换
[user02@localhost ~]$ su -
口令:
[root@localhost ~]#
[root@localhost ~]# vim /etc/passwd
将x去掉
user01:x:502:502::/home/user01:/bin/bash
user02:x:503:503::/home/user02:/bin/bash
修改为如下格式
user01::502:502::/home/user01:/bin/bash
user02::503:503::/home/user02:/bin/bash
保存后再进行切换实验,
[root@localhost ~]# su - user01
[user01@localhost ~]$ whoami
user01
[user01@localhost ~]$ su - user02
[user02@localhost ~]$ whoami
user02
[user02@localhost ~]$
现在可以实现无密码切换用户
转载于:https://blog.51cto.com/evils798/1420859