Ubuntu 16.04 Immediately Logs Out When SSH Into Server

November 5, 2019 204 views
Ubuntu 16.04

When I am trying to log into my Ubuntu 16.04 server via ssh I get immediately logged out after typing in the password. This is only for the justin user account.
I am able to briefly see this message:

Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-166-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:

0 packages can be updated.
0 updates are security updates.

Last login: Tue Nov  5 10:37:59 2019 from
Could not chdir to home directory /home/justin: Permission denied
/bin/bash: Permission denied
Connection to localhost closed.

It appears that it is some kind of error message, but when I log in via Root (which successfully logs in) and run ls -la /home/justin I get the following output:

root@ubuntu-servername:/home# ls -la /home/justin
total 260
drwxr-xr-x 12 justin justin  4096 Sep 29 12:44 .
drwxr-xr-x  3 root   root    4096 Jan 16  2018 ..
-rw-------  1 justin justin 17349 Sep 29 12:44 .bash_history
-rw-r--r--  1 justin justin   220 Jan 16  2018 .bash_logout
-rw-r--r--  1 justin justin  3794 Apr  2  2018 .bashrc
drwx------  3 justin justin  4096 Sep  2 12:37 .cache
-rw-r--r--  1 justin justin     0 Jan 16  2018 .cloud-locale-test.skip
drwxrwxr-x  2 justin justin  4096 Mar 28  2019 crons
drwxrwxr-x  3 justin justin  4096 Sep  2 12:39 dev
drwxrwxr-x  3 justin justin  4096 Jan 23  2018 documents
-rw-rw-r--  1 justin justin    80 Mar 21  2019 .gitconfig
drwx------  6 justin justin  4096 Sep  2 12:37 .local
-rw-------  1 justin justin   152 Mar 28  2019 .msmtprc
drwxrwxr-x  2 justin justin  4096 Jan 16  2018 .nano
-rw-r--r--  1 justin justin   655 Jan 16  2018 .profile
drwxrwxr-x  4 justin justin  4096 Sep 30 22:49 python
-rw-------  1 justin justin    58 Sep 25 12:17 .python_history
-rw-------  1 justin justin  1024 Aug 16  2018 .rnd
-rw-rw-r--  1 justin justin    75 Mar 28  2019 .selected_editor
drwx------  2 justin justin  4096 Apr 26  2018 .ssh
-rw-r--r--  1 justin justin     0 Jan 17  2018 .sudo_as_admin_successful
-rw-------  1 justin justin 14302 Sep 29 12:44 .viminfo

It appears as though every thing in the directory is correctly set to the justin permission group/user.
I have also run sudo chown justin:justin /home/justin but I get the same results.

I have restarted the droplet to just to make sure. I am not exactly sure where else to look for information concerning this error. If I could be pointed to a log file that might have more information that would be helpful.


1 Answer

Hi @LordOfBytes,

most probably the file /bin/bash is with root:root ownership and 0644 permissions.

bash should be executable by everyone. To make it executable by every user on your system, you would need to change it’s permissions

chmod 755 /bin/bash


  • I just checked and it does look like that is set correctly (see below). I am able to log into other users (non-root) without issue.

    root@ubuntu-servername:/home# ls -la /bin/bash
    -rwxr-xr-x 1 root root 1037528 Jul 12 15:26 /bin/bash

    I went ahead an ran the command anyways just for fun. After a reboot and that command it is still doing the same thing.

    Is there a way to like ‘reset permissions’ for that particular user?

    • Hi @LordOfBytes,

      Ah, in that case, most probably the user does not have shell enabled. Can you please try the following command

      sudo grep justin /etc/passwd

      And let me know what do you see there?


      • I ran that command for two users:

        root@ubuntu-servername:~# grep justin /etc/passwd
        root@ubuntu-servername:~# grep griffin /etc/passwd

        Note: The ######### is my phone number I just redacted for this comment.

      • It’s also weird because justin is part of the sudo group:

        root@ubuntu-servername:~# cat /etc/group | grep justin
  • Actually hold the phone…I just had two other users say they cannot ssh into their account either and they are both using /bin/bash.

    This does indeed look like an issue with /bin/bash. Is there more of an in-depth log to show more details about why it might be failing the permission check?

    I also just tried to create a new user using the /bin/bash shell and I am seeing the same message when SSH-ing into the server.

    • Hi @LordOfBytes,

      This is starting to sound like you have some odd permissions of the /bin folder not granting users to writes to execute it.


      • I have tried everything I could find online to investigate this. It does not look like there are any weird permissions for this.

        Some people think that the droplet might have been migrated and permissions were mixed up.

        I am just going to have to re-build the droplet at this point because no one has a solution for this.

        • Hi @LordOfBytes

          Rebuilding the droplet is a possibility as well. I’m sad we couldn’t reach the end of the issue. Anyway, please keep posting in the forum if you ever come across any issue again.


Have another answer? Share your knowledge.