Breaking the ice – solving frozen SSH on Raspberry OS

“I didn’t change anything and it (the SSH console) just kept on freezing”.
This sound like something a callcenter agent would hear many times a day. Not that I ever worked shifts in the night and early on weekends and got paid really well posing as some who knows more than the computer screen in front of him tells him to say. The good old Internet by call and Strato Tech Hotline days in the 2000s really helped my wallet as a student:)

Back to the topic. The SSH console on my Pi Zeros started at some point to freeze when I had just entered the password. Sometimes it wouldn’t even let continue from this point or at least reacted as slow as never before. Services were still running and my cron jobs which communicate with a MQTT server were still sending values and lighting up the connected LED stripe.

As my knowledge about Linux is very limited, Google was my friend and I found out that I wasn’t the only one with that problem:

https://raspberrypi.stackexchange.com/questions/12471/raspberry-pi-hangs-on-ssh-but-gives-feedback-from-a-telnet-terminal#69686

https://superuser.com/questions/820995/raspberry-pi-ssh-lag

From those posts I decided to try the following:
1) Add “IPQoS 0x00” to the end of each of the files /etc/ssh/ssh_config and /etc/ssh/sshd_config in the same directory.
2) Activate the line “#UseDNS no” in the file /etc/ssh/sshd_config by removing the “#”
3) Restart SSH service with “sudo service sshd restart”.

As the Pi Zeros have a headless installation, there’s no GUI and I have no adapters to physically connect the Pi Zero to a monitor and keyboard. This means I had to use the not really working SSH console to repair the SSH console. Sounds like fun.

After many tries I managed to sudo nano the ssh config files and after SSH was restarted there was no more freezing or lag whatsoever. I think it would have worked without 1) as at one point I couldn’t find the UseDNS line, only added IPQoS to the end of the file and didn’t want to risk the console to get frozen again. So I saved the file and restarted SSH and there was still lag. Check out what works in your case. I keep both changes as my PIs’ SSH console works fine now.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.