3

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

2 Answers 2

5

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.

1

try ssh with debug mode

ssh -vvvv username@host

if those output contain Authentication succeeded but then

Connection to *.*.*.* closed by remote host.
Connection to *.*.*.* closed.

if you can access the host machine, try ssh into localhost. If it was closed soon too, it may indicate the post process of ssh fail. afak if your account does not has a password but try with pubkey ssh-login will lead to this. ( some say that the permission under ~/.ssh will lead to this too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .