[openssh-server] kex_exchange_identification: Connection closed by remote host

Using your openssh-server via Synology’s container manager on my NAS. I’ve set the required variables, and I’m using PUBLIC_KEY to pass my pubkey. I can find the properly formatted pubkey I supplied in /config/.ssh/authorized_keys. /logs/openssh is empty (no current log file). I’ve set my PUID and PGID, and I’ve defined a USER_NAME. SUDO_ACCESS and PASSWORD_ACCESS are both set to false.

When I try to ssh in using ssh -i id_rsa -p 2222 myuser@mynasIP from my windows PC (where I generated my key), ssh returns:
kex_exchange_identification: Connection closed by remote host

Not sure how to troubleshoot it, especially since there’s no log. Any suggestions or tips welcome. I’m hoping it’s just something stupid I’m missing.

1 Like

SOLVED:

  • Ensure the host keys in /ssh_host_keys have the correct permissions.
    • *_key files should be 600
    • *_key.pub files should be 644

I have exactly the same issue. I’ve tried adding /config/.ssh/authorized_keys, and setting PUBLIC_KEY.

UPDATE I have gotten a step further:

If you look in the logs the host keys are all being ignored because they are 777. I believe the key files should be 600 and the key.pub files should be 644.

Now I have a standard permission error which implies the public key is setup incorrectly. I have it in /config/.ssh/authorized_keys.

UPDATE: Missing USER_NAME. :slight_smile: