0

At times when the remote device is behind a VPN or is in local network, this error shows up:

Connection failed with error: "Failed sending banner to ....@..........:22"

This shows up infrequently and is related to the connection being reset before the TCP connection is closed (I observed this via Termius [Microsoft Store] app for ssh and the error message had a warning before that mentioned TCP connection issues on closing ; though this error is not limited to Termius).

How to solve this?

1 Answer 1

0

I've found a solution that worked for me. Since this question wasn't asked here, I've asked the question and am posting my solution to it too.

Since the problem is due to an open TCP connection (assumption) to the remote machine with the SSH connection closing without closing the TCP connection ; a fix would be to remove the TCP server and resetting configs.

The steps I followed are:

  • Kill the dhcp service (dnsmasq)
  • remove the dhcp lease (/var/lib/dhcp/dhclient.leases)
  • remove openssh-* with configs ($ sudo apt purge openssh-*)
  • reboot the machine ($ sudo reboot)
  • DHCP will automatically request a new IP, check the IP (tip: $ ifconfig | head -n2).
  • Update package cache ($ sudo apt update)
  • Install openssh-server ($ sudo apt install openssh-server : this will chain install all dependencies)
  • Verify ssh from any other machine with new IP.

you can use apt-get in place of apt if you are more accustomed to it.

Do comment/answer if you found a different solution!

[Edit 1]

You should lookup what your dhcp service is, it was dnsmasq for me. It could be isc-dhcp-server or maybe something else.

1
  • I really don't think you have to reinstall everything to fix a single TCP connection getting closed rarely Commented May 16, 2021 at 17:24

You must log in to answer this question.

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