Linux Tricks and Techniques

For Linux Experts

Use the website for easy leaning of Linux

Wednesday, 24 August 2016

Root is not able to login : In Redhat and CentOS

Root is not able to login : In Redhat and CentOS



A system admin access a server by login as root because root is the super user and having all the permission for access the server's services. A root user can restrict or permit permissions for other users but other can not do this for root user. But there might be possibility when a root user is not able to login and the issue can not be resolved by login as other users. There might be another possibility if we are not able to login to console of the server from ILO . In this case it become more critical but a simple solution for this is given in one of my blog.






There are some possibilities that root is not able to login.Mostly the first thing which come into our mind is might be possible we forgot the password of root and we are not able to login. But apart of this there are other possibilities also which cause the root to not login.

Below are the troubleshooting steps to resolve the Root’s No Login issue

(1) Forgot the Root password:

This is mostly happen that we forgot the root password.For resetting the new password we have to boot the Server in Runlevel 1 .

Reset Root password in run level 1

(2)  Check the no login shell in /etc/passwd file .

[root@server ~]# grep root /etc/passwd
  root:x:0:0:root:/root:/sbin/nolgin

If you find the above /sbin/nologin in /etc/passwd file for root .Change its login shell into /bin/bash

usermod -s /bin/bash root

for eg.

[root@server ~]# usermod -s /bin/bash root
[root@server ~]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash

(3) Check the root account expiration date.

chage -l root  (it will show the account information,check the account expiration date).

If it is expired than change it .For troubleshooting purpose I am giving it as Never Expired. For more info read man page “man chage ”

chage -E never root

[root@server ~]# chage -l root
Last password change                                    : Sep 17, 2011
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7
[root@server ~]#

(4) Check “nologin” directory in /etc

Check nologin directory in /etc . If you find then remove it with help of rm command

ls -ld /etc/nologin && rm -fr /etc/nologin

(5) Check the permission of /etc/securetty

If the permission of file /etc/securetty is other than 644 than it is also one of the problem.

change /etc/securetty file permission to 644

chmod 644 /etc/securetty

(6) Check the /etc/securetty  file’s content

The securetty file must have below given contents and in same manner. If you find something is missed then edit the file.

[root@server~]# cat /etc/securetty
console
vc/1
vc/2
vc/3
vc/4
vc/5
vc/6
vc/7
vc/8
vc/9
vc/10
vc/11
tty1
tty2
tty3
tty4
tty5
tty6
tty7
tty8
tty9
tty10
tty11
[root@server ~]#

(7) If you are trying with ssh to remote host , might be possible in ssh configuration file login to root is not permitted.

[root@server ~]# grep Root /etc/ssh/sshd_config
PermitRootLogin no
[root@server ~]#

Then change the value “PermitRootLogin yes” in /etc/ssh/sshd_config

And reload or restart the sshd service.

/etc/init.d/sshd reload   

OR

No comments:
Write comments