I had the same problem as ssh connection to server closed after authentication immediately I connected to my server (in this case a raspberry pi running pi musicbox) via ssh, it would accept my password and then instantly close the connection--long before I might have followed one suggestion to hit ^C.

I am posting this duplicate of that question because I managed to solve my problem, but I am new to this site and don't have 10 rep from this site to post on a "protected" question (despite my "association" bonus of 100 rep based on other stackexchange sites). You can see me whine about this here, where @slm made the constructive suggestion that I submit my own question and answer.

For a bit more context, the default login on the pi musicbox is root; I created another personal login to store my music so that I wouldn't always be logging in as root. I did this with the command:

useradd -c "Joe Schmo" -d /home/jschmo jschmo

The problem was that I had created a new user but had not created a home directory. SSH closed the connection immediately, but logging in locally gave me a message saying that the home directory did not exist. I tried to create the directory manually with mkdir /home/jschmo running as root, but that ran into permission problems.

I deleted the user and ran the adduser command again using the -m flag to create the home directory.

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.