I have new brand new Dell with Ubuntu 16.04.02 LTS pre-installed. I've done updates, setup a local account and installed ssh.

When I try to ssh into the machine it asks for my password, prints "Welcome to Ubuntu", "last login: Thu..." and then "Connection closed".

This happens from remote systems, or locally when I run


The problem is just login sessions, it works if I give it a command like

ssh /bin/date

I can even get a minimally working shell but it isn't attached to a tty so lots of things don't work.

ssh /bin/bash -i

The account uses bash. The startup scripts are unchanged from the ones in /etc/skel, just .bashrc and .profile. I've tried moving them aside. Based on an old answer I have verified that they don't have an exit in them.

I'm using a normal user account; not root.

  • Try ssh -t /bin/bash -i. The -t asks for a TTY allocation. – muru May 26 '17 at 2:18
  • For fun, grep your_username /etc/passwd and see if anything is funky there. Unless the VAR or you changed something, what you are trying to do should work swell. Also, you could try ssh -l localhost using a different username. If this works that would eliminate a lot of possibilities. Lastly, after you ssh localhost, cat /HOME/.bash_history and see if there is an unexpected exit or quit at the end of it. – jones0610 May 26 '17 at 4:06
  • muru, thanks for the ssh -t tip. It does successfully work around the current problem and would have been great to know countless times in my past when trying to login to partially wedged systems. – J Prescott Jun 1 '17 at 14:57

I was able to isolate the problem by adding debugging statements to /etc/profile to trace early startup.

Dell has added a file /etc/profile.d/display-toggle-keybinding.sh to fiddle with some keybindings. That file starts with:

if [ -z "$DISPLAY" ]; then  
   exit 0  

Since things in /etc/profile.d are sourced, they run in the current shell rather that a subshell, so when they exit it kills off the whole session.

Once I saw the problem it was easily verified by trying

ssh -X

which worked fine. The -X enables X11 forwarding which means that DISPLAY is set. The problem only occurs when DISPLAY is not set.

You can correct the problem by editing /etc/profile.d/display-toggle-keybinding.sh and changing the "exit 0" to "return 0". "return" is a slightly less powerful version of "exit" which only exits the file currently being executed.

The comment in the file indicates that it is from package "dell-wmi-aio" so it may be unique to AIO systems. I'm using an Optiplex 7450 AIO.

I found the answer to this question to be very helpful in describing how the various types of bash shells (interactive, login, graphical etc) differ and what their startup sequences are:
Scripts in /etc/profile.d Being Ignored?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.