I'm being automatically logged out immediately after login.

April 17, 2018 791 views
DigitalOcean Ubuntu 16.04

Hi,

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?

Thanks

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

Have another answer? Share your knowledge.