Lately I haven't been able to connect to my Pi without rebooting it every day. After a reboot, I am able to connect to it for a few hours and then it starts giving the "Network error: Connection timed out" message over Putty. I also tried using WinSCP and that gives me a "Host unreachable" error. What should I do?
There are several things to check:
- is the Pi completely frozen? Attach HDMI-Monitor and USB-Keyboard to check
- if it's still alive check the logs for errors
- maybe the SD card is bad?
Edit: Attach Monitor and Keyboard and check if sshd is still running
ps aux | grep sshd
sudo journalctl _COMM=sshd
sudo service ssh restart
It's not a problem I have seen with a pi but have seen it on a server running SuSE Linux. The SSHD daemon was aborting and not restarting. I fixed it by editing the service definition file
I commented out a line preventing it from restarting after failure and and added a line forcing it to restart.
[Unit] Description=OpenSSH Daemon After=network.target
[Service] Type=notify EnvironmentFile=-/etc/sysconfig/ssh ExecStartPre=/usr/sbin/sshd-gen-keys-start ExecStartPre=/usr/sbin/sshd -t $SSHD_OPTS ExecStart=/usr/sbin/sshd -D $SSHD_OPTS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=restart-always RestartSec=5 #RestartPreventExitStatus=255 TasksMax=infinity