0

I have a Linux desktop that I connect to with my laptop to do things. my problem is that at first try or after sometime ssh client on my laptop returns:
ssh: connect to host port 22: host is down
but after pinging my laptop from my PC then ssh works. my computers are connected through a Dlink DSL-2740U wireless router. Is there any way that I could keep this connection up so I wouldn't have to reinitialize it by pinging my laptop?

P.S. I'm not trying to keep ssh connection alive I'm trying to keep IP connection between my computers alive hopefully by configuring some thing in my router.

S.Rad
  • 307
  • 2
  • 10
  • Possible duplicate of [Keep SSH session alive](https://stackoverflow.com/questions/25084288/keep-ssh-session-alive) – Romeo Ninov Dec 21 '18 at 20:09
  • I'm mostly asking this question out of my lack of knowledge in wireless field if this was a wired connection I'd just setup some static route between my computers. – S.Rad Dec 21 '18 at 21:02

2 Answers2

0

In your client, file ~/.ssh/config you can set this record:

Host *
    ServerAliveInterval 300

To keep alive your host every 5 minutes. Also you can add under above lines

ServerAliveCountMax 5

To limit the number of nonresponces from server

Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31
  • I had already done that, good thing yes but doesn't help much when I quit the disconnect ssh and want to connect later. – S.Rad Dec 22 '18 at 09:17
  • @S.Rad, in such case you can try to play with power management of wireless controller of laptop. But this depend a lot from the OS you use. – Romeo Ninov Dec 22 '18 at 09:35
  • I managed to fix it by doing some Wireshark monitoring and help of a post in superuser.com which I've referenced in my answer, It became evident that arp cache in my laptop was sticking to a wrong value. – S.Rad Dec 22 '18 at 13:44
  • @S.Rad, so this is issue of your OS, not ssh problem. – Romeo Ninov Dec 22 '18 at 14:21
  • That's what I'm pretty much sure of, should I edit my question? – S.Rad Dec 22 '18 at 15:10
  • @S.Rad, you can add it as clarification to your answer :) – Romeo Ninov Dec 22 '18 at 15:15
0

So the the root of evil's my laptop being a macbook; Here!'s a similar issue. The answer by Arnaud Léonard helped me. While pinging my PC I saw my laptop was generating a lots of arp requests details are not relevant but I concluded that it's an OS problem, so I used

    sudo arp -d <my-pc-ip-addr>  

in the laptop and problem solved! My assumption is removing the arp cache has allowed new arp resolution to succeed which were already failing due to cache not getting updated.

S.Rad
  • 307
  • 2
  • 10