Wednesday, May 13, 2015

How to fix ssh disconnects/drops

So I disabled ipv6 on my eth0 and tun0 devices on cubox-i4pro by using the following method:
sudo nano /etc/sysctl.d/40-ipv6.conf
# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
net.ipv6.conf.tun0.disable_ipv6 = 1
I then rebooted for the changes to take effect:
sudo nano /etc/sysctl.d/40-ipv6.conf
sudo systemctl reboot
After the system came back online I ssh'd in and continued on configuring my Arch Linux installation. However, I was repeatedly interrupted because my ssh connection kept disconnecting. I started to research and found that ssh was still attempting to listen on ipv6. Here's how I found it:

sudo journalctl -u sshd
And the output of concern....

May 10 16:16:10 cuboxi4 sshd[1705]: debug3: sock_set_v6only: set socket 4 IPV6_V6ONLY
May 10 16:16:10 cuboxi4 sshd[1705]: debug1: Bind to port 23000 on ::.
May 10 16:16:10 cuboxi4 sshd[1705]: Server listening on :: port 23000.
To fix it, I modified the ssh daemon configuration file like so:

sudo nano /etc/ssh/sshd_config
Change this...

#AddressFamily any
To this...

AddressFamily inet
Of course you then must either reboot or restart sshd for the changes to take effect. I opt for restarting sshd:

sudo systemctl restart sshd
What this does is change sshd from using both IPv4 AND IPv6 to just IPv4. I hope this helps someone!

No comments:

Post a Comment