Connection refused for ssh (linuxserver/openssh-server) reddit / selfhosted ---------------------------------------------------------------------- Milamber_sb · 2023-12-30 22:10 Hi! There is a dockerised ssh server on Synology to give limited access to certain folders (at least it is the goal). I have connected linuxserver mods, copied public key to authorised\_keys, tinkered with docker environment variables, firewalls checked etc. In the end I get this message: ssh: connect to host 192.168.0.100 port 19003: Connection refused Out of ideas and google searches... Does anyone have any clue how to poke it until it moves? :) ​ Update 1: During additional trials and errors I get this message: kex_exchange_identification: Connection closed by remote host Connection closed by 192.168.0.100 port 19003 It seems sshd declines all connections... P.S. thanks to [**wplinge1**](https://www.reddit.com/user/wplinge1/) to point out my trailing error. Yesterday I had this message as well (with reset): kex_exchange_identification: read: Connection reset by peer Connection reset by 192.168.0.100 port 19003 ​ Here is docker-compose: version: "2.1" services: openssh-server: image: lscr.io/linuxserver/openssh-server:latest container_name: openssh-server hostname: openssh-server #optional environment: - PUID=1026 - PGID=100 - TZ=Europe/Tallinn # - PUBLIC_KEY=yourpublickey #optional # - PUBLIC_KEY_FILE=/path/to/file #optional # - PUBLIC_KEY_DIR=/path/to/directory/containing/_only_/pubkeys #optional # - PUBLIC_KEY_URL=https://github.com/username.keys #optional - SUDO_ACCESS=true #optional - PASSWORD_ACCESS=true #optional - USER_PASSWORD=qwer #optional # - USER_PASSWORD_FILE=/path/to/file #optional - USER_NAME=user1 #optional # - LOG_STDOUT= #optional # - DOCKER_MODS=linuxserver/mods:openssh-server-ssh-tunnel volumes: - /volume1/docker/ssh-server/:/config - /volume1/docker/ssh-server2/:/folder1 ports: - 19003:2222 restart: unless-stopped log: [mod-init] Attempting to run Docker Modification Logic [mod-init] Adding linuxserver/mods:openssh-server-ssh-tunnel to container [mod-init] Downloading linuxserver/mods:openssh-server-ssh-tunnel from lscr.io [mod-init] Installing linuxserver/mods:openssh-server-ssh-tunnel [mod-init] linuxserver/mods:openssh-server-ssh-tunnel applied to container [migrations] started [migrations] no migrations found ─────────────────────────────────────── ██╗ ███████╗██╗ ██████╗ ██║ ██╔════╝██║██╔═══██╗ ██║ ███████╗██║██║ ██║ ██║ ╚════██║██║██║ ██║ ███████╗███████║██║╚██████╔╝ ╚══════╝╚══════╝╚═╝ ╚═════╝ Brought to you by linuxserver.io ─────────────────────────────────────── To support LSIO projects visit: https://www.linuxserver.io/donate/ ─────────────────────────────────────── GID/UID ─────────────────────────────────────── User UID: 1026 User GID: 100 ─────────────────────────────────────── User name is set to user1 sudo is enabled with password. sshd is listening on port 2222 User/password ssh access is enabled. TcpForwarding is enabled [custom-init] No custom files found, skipping... [ls.io-init] done. P.S. 200% it would be some obvious and easy fix I have overlooked... ---------------------------------------------------------------------- ro55mo · 2023-12-30 22:29 It says (at least to me) that sshd is listening on port 2222 but you are trying to connect on 19003. ---------------------------------------------------------------------- Eirikr70 · 2023-12-30 22:49 I'd try and find if the problem is on another layer (firewall or whatsoever). A question just in case : you are sure that your server's address is fixed to 192.168.0.100 ? ---------------------------------------------------------------------- wplinge1 · 2023-12-30 23:10 I think the port mapping you specify is ignored when using `network_mode: host`, so it really is just listening on 2222. ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 09:02 I have tried without defining `network_mode: host` \- same result... ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 09:03 2222 is a container port, it is mapped to 19003: ports: - 19003:2222 ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 09:06 *I'd try and find if the problem is on another layer (firewall or whatsoever).* === yeah, I have the same thoughts. But I have tried everything :) ​ *A question just in case : you are sure that your server's address is fixed to 192.168.0.100 ?* === yes, I have a fixed IP for the server. Everything else is working as intended. ​ *Edit : also, the combination of UID and GID is strange. Sure it is ok ?* === meanwhile they are correct :) For DSM (Synology), it usually 1026 and 100 for the first created user during setup. ---------------------------------------------------------------------- wplinge1 · 2023-12-31 09:19 I just tried the compose myself and it worked as expected (without the `network_mode`): I was able to connect with `ssh -p 19003 user1@127.0.0.1` Do you have local shell access with Synology? If so, it'd be good to check `docker ps` is as expected and maybe try `ssh -p 19003 127.0.0.1` in case it's a Synology firewall getting in the way or something. Once the host issue is resolved my money's on firewall. ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 09:30 I've looked to other docker-compose files, this host network with port mappings has been a trailing error for several of them... Still I wish it would have solved the issue :) ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 09:45 `kex_exchange_identification: Connection closed by remote host` Here is a similar problem [kex\_exchange\_identification: Connection closed by remote host](https://stackoverflow.com/questions/67000681/kex-exchange- identification-connection-closed-by-remote-host) It was solved by `chmod 0600 ` ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 09:47 I have switched off the firewall completely :) ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 09:47 still it is worth a try. why not. ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 09:53 >ssh -p 19003 user1@127.0.0.1 it gave my one-liner: `kex_exchange_identification: Connection closed by remote host` ​ I have deleted all keys from authorized\_keys, same result. ---------------------------------------------------------------------- Milamber_sb · 2023-12-31 10:12 If you are on Mac OS Ventura, and you have `kex_exchange_identification: Connection closed by remote host`, this might fix your issue: [My SSH connections are failing with kex\_exchange\_identification](https://forum.remote.it/t/my-ssh- connections-are-failing-with-kex-exchange-identification/856)