SSH disconnects when waking up from sleep

Joined
Nov 9, 2015
Messages
2
Reaction score
0
Points
1
#1
I'm using El Capitan 10.11.1, everytime I wake up my computer from sleep my SSH connection disconnects with a message showing in the terminal

Code:
Write failed: Broken pipe

A message also appears in the System Log inside Console saying

Code:
11/6/15 4:02:36.559 PM configd[51]: network changed: v4(en0-:192.168.1.70) DNS- Proxy-
11/6/15 4:02:40.468 PM configd[51]: network changed: v4(en0+:192.168.1.70) DNS+ Proxy+ SMB

I searched for a solution and tried several things already like adding parameters in ssh_config, signing in to iCloud, settings a manual IP address, having the HDD not going to sleep in the Energy Saver settings and none worked. The only workaround I've found that works is settings the Computer Sleep settings to Never in the Energy Sleep settings but that doesn't seem like a good in the long run.

Does anyone have a solution for this issue?

Thanks
 
Joined
Jul 2, 2007
Messages
3,494
Reaction score
204
Points
63
Location
Going Galt...
Your Mac's Specs
MacBookAir5,2:10.13.6-iMac18,3:10.13.6-iPhone9,3:11.4.1
When the OS is sleeping or hibernating, there are no keepalives aren't being sent. Even if is is set to "yes" in sshd_config, the OS is asleep and not sending them. That's why you get the broken pipe message. SMB isn't ssh, and in my estimation it's a red herring as far as ssh specifically goes. There is freeware for Linux/Unix that gets around this. You might try using "screen" from the command line in OS X if you just want to keep a remote ssh login going so you can pick up where you left off on the other computer and processes keep running on it when you lose a connection.
 
OP
L
Joined
Nov 9, 2015
Messages
2
Reaction score
0
Points
1
I use tmux for the SSH sessions but I guess I'll have to disable the computer sleep if there's no solution that doesn't involve re-connecting 10+ SSH sessions every time I wake up the computer
 
M

MacInWin

Guest
You can adjust the sleep settings to let the screen go blank, but keep the CPU awake. That's how I'm set up. The power usage for the heartbeat CPU activity is really minimal. You can even let the drives spin down (although I don't because I have an SSD) but that may make the machine to slow to respond to the network keepalives.
 
Joined
Jul 2, 2007
Messages
3,494
Reaction score
204
Points
63
Location
Going Galt...
Your Mac's Specs
MacBookAir5,2:10.13.6-iMac18,3:10.13.6-iPhone9,3:11.4.1
I use tmux for the SSH sessions but I guess I'll have to disable the computer sleep if there's no solution that doesn't involve re-connecting 10+ SSH sessions every time I wake up the computer

You could try to use screen and do some testing. I haven't tried it to solve issues related to a system going to sleep, but it works fine on my AIX and Linux boxes for VPN sessions that die, bad Wifi and other such network interrupts. I'd assume that screen persists through a sleep cycle, though I don't know if it can continue to communicate or do whatever it needs to under the covers while in sleep mode on a Mac. It's free and included in OS X, so why not give it a shot?

Here's a quick general rundown...

http://www.ibm.com/developerworks/aix/library/au-gnu_screen/
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top