SSH not working after router restart

Hi there,

I always have the same issue, whenever I restart my router I can not connect to my PI over SSH.
That one is caused by network interruption.
Is there a service or some command that I can restart/run to fix this issue?

So far I have to restart my PI and that’s not so easy specially when someone else is watching TV…

I do have webmin installed on my PI so I can run some custom commands or restart services even if SSH connection is not possible…

Thanks!

I really don’t understand how you have things configured to allow you to use webmin, if you don’t have a network connection.

My workaround would be to use a fixed IP address for the Pi, and then, as long as the router is providing service the Pi should be contactable.
Derek

First thing to mention is that my PI is connected via cable.
A router restart generates just a short network interruption (1min), after that Kodi and nearly any other service like nginx, VPN , etc… are running ok expect SSH.
So the PI has a static DHCP config on the router, so that always will get the same IP, but still same issue.

Earlier today I saw this link posted, and it has good stuff.
For a start it looks like you could run

systemctl list-units |grep ssh to get current status of SSH,
and then use other systemctl commands to restart SSH
Can you do that via webmin?
Derek

> systemctl list-units |grep ssh
ssh.service                         loaded active running   OpenBSD Secure Shell server
> systemctl stop ssh.service
> systemctl start ssh.service

This didn’t help …still no connection… :frowning:

That says to me that there is something ‘booked’ which will get cleared by a reboot - but not just by the stop/start.
Did you think to try the reload … ?
Derek

Check /sbin/ifconfig before and after reboot. Sounds like IP change

Sam

Sorry but I’m really sceptical of this problem - OpenSSH binds to INADDR_ANY which means that it listens on all interfaces and it does not matter if the interface goes down or comes back up or not, or whether it gets a different IP address - it will always accept connections. No need to stop and restart anything.

Your systemctl status line clearly shows OpenSSH is still running.

I’ve interrupted the network connection hundreds maybe thousands of times during OSMC testing/development (both Ethernet and Wifi) and never once had problems with the SSH server mysteriously not responding yet other services are working. Nor has anyone else reported the same issue on the forum.

I strongly suspect that some 3rd party software you have installed is causing this issue and that you would not see it if you did a fresh install. You say you have webmin installed - webmin can be fairly invasive as it basically edits/controls the configuration files of many system daemons, and I doubt that it is fully compatible with Debian Jessie running systemd and connman as the network manager, as connman is a bit non standard in this application.

Is there anything else you have installed such as firewall software, or things like fail2ban ?

Finally, are you trying to connect via IP address or are you relying on a hostname such as osmc.local ?

It maybe that Webmin changed something, I was not aware that is not fully compatible with jessie :frowning:

I have installed several software on my PI aside from the standard… would be quite hard to remember all of them now :stuck_out_tongue:, but maybe some of them, Couchpotato, sickrage, google coder, openVPN + iptable rules needed, mosh …

I always use ip address.
Strange think I had this issues in the past also with raspbmc…

@sam_nazarko
This is the output from ifconfig:

>  /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:0d:f2:1f  
          inet addr:192.168.1.33  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4740931 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1412223 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1940191339 (1.8 GiB)  TX bytes:249747867 (238.1 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:93315 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93315 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:14185111 (13.5 MiB)  TX bytes:14185111 (13.5 MiB)

the IP didn’t change cause the MAC address from my PI is registered on my router for static address.

thanks allot for your support guys…

P.S: I do have a tp-link running DD-wrt, can that have any influence?

UPDATE: it seams only from my PC I can’t connect which is also connected via cable.
From my android phone it works… sorry for bothering you with stupid questions…