Thursday 25 June 2020

panic cannot login to linux

Panic ! Thats what occurs when a critical systems you manage cannot login , but the service was running properly.


Recently i do some changes on the /etc/security/limits.conf and it make all lockout. No SSH can be done, but all the service was running properly.

To the rescue, we need to login to the systems and revert back changes, and to do that we need to go into single mode.

We do on Centos 7.x systems which is the grub boot loader is different than the old version.

So how to do it step by step, and no panic. 

  • Reboot your machine and immidiately go to rescue mode.
  • Chose one boot options and press "e" to change the entry
  • Look for below entry :
    linux16 /boot/vmlinuz-3.10.0-123.el7.x86_64 root=UUID=act2884249823928928392 ro  xxxxxx
  • Change the ro to below 
    rw init=/sysroot/bin/sh
  • Then continue the boot, press ctrl+x to do that. No worries, after finish you can reboot and the grub boot loader will be still the old one.
  • once boot to single mode you need to mount the filesystem. do
    # chroot /sysroot/
  • After this step you can revert back any settings you made to restore it to working state.
  • On our side, its /etc/security/limits.conf
  • After finish we can reboot the machine to production mode
    # reboot -f
That was no panic attack anymore if you know what you are doing.

Always make sure you have backup of the OS.
Or better way use Container these days. 


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More