I'm being automatically logged out immediately after login.

Posted April 17, 2018 17.5k views
DigitalOceanUbuntu 16.04


One of my usernames logs out immediately after login. When logging in through .ssh I get an error saying Permission denied (publickey,password). When logging in through the console I am immediately logged out.

All the other usernames, including root, are working fine.

How can I fix this issue?


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

It sounds to me like this user may have an invalid shell set. When you log into Linux on the command line it will execute the assigned shell for that user and that is where your session occurs. When you type exit it closes the shell and your connection terminates. If you have an invalid shell set, your droplet will attempt to start what is defined, find it cannot and exit.

You can ensure the correct shell is set for the user by running the following as root:

usermod --shell /bin/bash your_username

for bash or

usermod --shell /bin/sh your_username

for sh.

Wow, that worked immediately. I had searched the net for days, but in the future I’ll ask here immediately.

Thank you