mesand
Posts: 65
Joined: Tue Oct 22, 2019 9:21 pm

SSH timeout trouble

Wed Nov 13, 2019 7:39 pm

Hello,

sometimes its easy to ssh into my pi and sometimes it times out and wont work even after restarting both pi and computer. usually after a connection closes abruptly i will have trouble ssh back to the pi

epoch1970
Posts: 4775
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: SSH timeout trouble

Thu Nov 14, 2019 1:25 pm

Something looks wrong with your network. Perhaps the IP addresses change often, or the transport layer (wireless or ethernet) gets disrupted.
Try using ethernet if possible, it is most stable normally.
Check the condition of your router and network.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Lewis-H
Posts: 26
Joined: Thu Oct 31, 2019 12:45 pm

Re: SSH timeout trouble

Thu Nov 14, 2019 2:30 pm

A couple of things to try:

Are you able to ping the Raspberry Pi from the Windows machine, open a command prompt and enter ping 192.168.0.198 (but with the IP address you are using for SSH), if you get replies the connection is good if not there is a networking problem preventing SSH working
Did you set-up SSH using raspi-config, or did you set it up yourself, if you set it up yourself can you tell us how (there may be a set-up issue with SSH)
Can you log in to SSH from the Raspberry Pi itself, use ssh 127.0.0.1 (actually use 127.0.0.1), if this does not work then it is likely that SSH is not set-up correctly, the error may give a clue to the problem.
Can you now try to log in to SSH from the Raspberry Pi itself, but this time use the actual address and port ssh 192.168.0.198 -p 22 (but with the IP address you are using for SSH), if this does not work it may point to a problem with the firewall on Linux, or that SSH is set-up to only use certain connections or a different port number
If all of the above work fines then it is probably something like a firewall problem with the router, it may help to try some different port numbers
To add extra port numbers do the following:

Backup the SSH configuration using sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.old
Edit the SSH configuration using Sudo nano /etc/ssh/sshd_config
Look for the line that says Port 22
Add some additional lines below with some other port numbers, I would suggest a different well-known number, e.g. Port 80, and a largish number, e.g. Port 55555
Restart the SSH service using Sudo /etc/init.d/ssh restart
Try using putty with each number you added in turn, in my case 80 does not work because we have a web server the router forwards to, but 55555 worked fine
Hopefully, something here helps!
Regards,
Lewis

Return to “General discussion”