Centos common user su to root prompts error, centosroot
1. When a common user in CentOS7 executes SU, the following error is reported:
[test@ecs-1453 ~]$ su -Password: su: Authentication failure
Solution: If the root user can log on to the system normally, use the root user to log on to the system first, and then perform operations 1. log on to the root account;
2. Execute sudo-I
[root@ecs-1453 ~]# sudo -i
3. Run chmod + s/bin/su.
[root@ecs-1453 ~]# chmod +s /bin/su
4. Verification
[test@ecs-1453 ~]$ su - rootPassword: su: Authentication failure[test@ecs-1453 ~]$ su - rootPassword: Last login: Tue Feb 27 18:44:34 CST 2018 on pts/0Last failed login: Tue Feb 27 18:45:42 CST 2018 on pts/1There was 1 failed login attempt since the last successful login.
2. When a common user in centos6 executes su, the following error is returned:
[test@ecs-19cb ~]$ su - rootPassword: su: incorrect password
Solution:
If the root user can log on to the system normally, use the root user to log on to the system first, and then perform operations 1. log on to the root account;
2. View/etc/pam. d/su configuration file, # auth required pam_wheel.so use_uid is enabled. If yes, the user (usermod-g? The User ID of the wheel user) can be su, or a Password error will be prompted.
[root@ecs-19cb ~]# vim /etc/pam.d/su
#%PAM-1.0auth sufficient pam_rootok.so# Uncomment the following line to implicitly trust users in the "wheel" group.#auth sufficient pam_wheel.so trust use_uid# Uncomment the following line to require a user to be in the "wheel" group.#auth required pam_wheel.so use_uidauth include system-authaccount sufficient pam_succeed_if.so uid = 0 use_uid quietaccount include system-authpassword include system-authsession include system-authsession optional pam_xauth.so
3. Check the file permission as follows:
[root@ecs-19cb ~]# ll -a /bin/su?-rwsr-xr-x. 1 root root 34904 May 11? 2016 /bin/su[root@ecs-19cb ~]# ll -a /usr/bin/passwd?-rwsr-xr-x. 1 root root 30768 Nov 24? 2015 /usr/bin/passwd
4. Verification
[test@ecs-19cb ~]$ su - rootPassword:?su: incorrect password[test@ecs-19cb ~]$ su - rootPassword:?[root@ecs-19cb ~]#