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.