Unable to login to host via ssh, just see 'Connection closed' in authlog

13,470

Solution 1

Doing a comparison of the authorized_keys file it turns out it didn't quite match the one on the host it was copied from (4 byte difference in length). Recopying the contents resulted in being able to login.

I had hoped the /var/log/auth.log file would have been cleared as to the key being invalid, though I believe this could have been achieved by adjusting the log level in /etc/ssh/sshd_config (defaults to INFO).

Solution 2

Is the ssh service running on the remote (Ubuntu) machine? Test it with: sudo service ssh status

If it isn't installed add it with: sudo apt-get install open-ssh server

You can configure the service if needed with:

sudo vi /etc/ssh/sshd_config

but make sure you know what you want to do before editing that file.

To restart the service, do:

sudo service ssh restart.

Share:
13,470

Related videos on Youtube

Andre M
Author by

Andre M

Updated on September 18, 2022

Comments

  • Andre M
    Andre M over 1 year

    I am trying to allow a user remote access to a Linux host, for purposes of continuous deployment, but I am not sure why the user can not get connect to the host, despite the public key being setup.

    On the host machine there are the following files in the user's ~/.ssh folder:

    • authorized_keys
    • config
    • github.project1.key

    These files and their contents match the contents of the user's ssh folder on another host, where we are able to connect.

    Connectivity from remote host is tested via (not the real values):

    ssh validuser@devhost -i ~/.ssh/myprivatekey.key
    

    For that we get:

    Permission denied (publickey)
    

    Trying to analyse the situation on the host, the /var/log/auth.log, I just see this entry appear:

    Oct 16 14:59:10 devhost sshd[24020]: Connection closed by 62.70.23.213 port 51759 [preauth]
    

    Oddly enough, if I try an invalid user (no accout on host) during ssh, I get:

    Oct 16 15:11:17 devhost sshd[24069]: Invalid user xubuntu from 67.70.26.223
    Oct 16 15:11:17 devhost sshd[24069]: input_userauth_request: invalid user xubuntu [preauth]
    Oct 16 15:11:17 devhost sshd[24069]: Connection closed by 62.70.23.213 port 51888 [preauth]
    

    Other things of note:

    • default user is ubuntu, for which which we can access
    • there is no /etc/nologin
    • as far as I can tell from /etc/passwd is permitted login, based on bash being specified as shell
    • host is a hosted Ubuntu based VM

    Does anyone have any ideas?