RHEL 7 Slow Login - Delay in SSH login



RHEL 7 Slow Login - Delay in SSH login 


Why does it take a long time to get on login prompt after successful authentication with ssh with correct credentials?


ISSUE:

  • It takes more than 20 sec to login with ssh
  • Delay happens after successful login authentication 
  • you find below error message in /var/log/secure 
sshd[19312]: pam_systemd(sshd:session): Failed to create session: Connection timed out

RCA:

  • pam_systemd create CreateSession method in systemd-logind via DBus, and this means systemd-logind is unable to reply pam_systemd.
  • Sometimes the machine gets stuck or hangs during boot or due to high load.
  • 'systemd-logind' following output error meaning, meaning that some directories have incorrect permission.
systemd-logind[681]: Failed to save session data /run/systemd/sessions/28: File exists
systemd-logind[681]: Failed to save user data /run/systemd/users/0: File exists

How To Fix This Login Delay in SSH:


  1. Check the permission of the below directories this should be 755, If not then fix it.
  • /run/user
  • /run/systemd/users
  • /run/systemd/sessions
After the above status if the issue not fixes then we have to restart the below services step by step to resolve this issue.

1. You have to reload the system login based daemon

 # systemctl daemon-reload

2. Check the health status of the inter-process communication daemon

# systemctl status dbus.service
# systemctl status polkit.service 

3. If the dbus and polkit service is not running then you will start the first polkit service then we will start the dbus service. Please make sure this will start in the same order.

# systemctl start polkit.service
# systemctl start dbus.service

4. In the last step we have to restart the systemd-logind service

 # systemctl restart systemd-logind
 
That's it, now you have successfully fixed the issue. This is in the case when you have sufficient space in the root partition and load if optimal. If you have both issues then you have to fix them first. 
Now you have added one more troubleshoot option in your skill.

Share the article if it helps you !!!

Post a Comment

0 Comments