ssh connections dropping

since upgrading to lion ssh connections constantly drop with:

Write failed: Broken pipe


this did not happen in snow leopard, nor does it happen on win7 pro in parralels

apple terminal, zoc, and securecrt all experience the same thing


did apple change an idle timeout setting or something?

MacBook Pro, Mac OS X (10.7)

Posted on Aug 16, 2011 6:55 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 14, 2012 8:20 AM

The changes mentioned towards the bottom of this page by subq seem to have fixed this issue for me:


http://subq.surfing.net/os-x-lion-terminal-ssh-tweaks


12 hours+ and the issue has not resurfaced. However, making these changes to your user's ssh config under your own account are more preferable due to future updates overwriting them if made in /private/etc/ssh_config.

38 replies
Question marked as Top-ranking reply

Jan 14, 2012 8:20 AM in response to blist

The changes mentioned towards the bottom of this page by subq seem to have fixed this issue for me:


http://subq.surfing.net/os-x-lion-terminal-ssh-tweaks


12 hours+ and the issue has not resurfaced. However, making these changes to your user's ssh config under your own account are more preferable due to future updates overwriting them if made in /private/etc/ssh_config.

Aug 17, 2011 9:00 AM in response to nsouto

I haven't tried changing the ssh config yet just because I haven't gotten around to it, however, running options at the cli when you make a connection should fix the problem.


ssh -o TCPKeepAlive=no -o ServerAliveInterval=15 username@remotehost


This does not fix meerkat from disconnecting and reconnecting all day long though if I am not actually tunneling traffic through it the whole time.


You could always fallback to actual tcp keep-alives but it generally isn't recommended.


SecureCRT NO-OP works as expected and that is what I have been doing for remote host ssh work. I can do ssh tunneling/port forwarding through SecureCRT as well but I prefer meerkat because I can just turn different tunnels on and off with a single click.


When I get some time I will probably adjust my local ssh config so that I don't have to type the options out everytime I make a connection. SecureCRT NO-OP will do in the meantime.


Hope that helps.

Sep 8, 2011 5:47 AM in response to blist

Stupid question. Is it possible that the DHCP IP address lease is turning over to quickly AND each time it is getting a new IP address.


If the Mac were getting a new IP address each time the DHCP lease needed to be renewed, that would break any TCP connection.


As an experiment, can anyone having this problem try switching to a manually assigned IP address and see if the problem continues?


Or write a script to capture the "ifconfig" information once a minute, and then see if the IP address has changed between when the ssh (or RealVNC) connection was made and when it received SIGPIPE.


#!/usr/bin/env bash

while sleep 60

do

ifconfig

done >ifconfig.history.txt


again, this is just a wild guess.

Dec 8, 2011 11:47 AM in response to blist

try this !!!


I copied the Terminal.app folder from /Applications/Utilities from a Macbook running Snow leopard or Leopard (dont remember which of two) and put it in my personal folder on OS Lion. Running this version of Terminal seems to be doing fine.


I am on ssh all day and the ssh connection would close on me every few hours.

I have been running the Snow Leopard version of Terminal for about half a day and no drops so far.


will update!!


amit

Dec 16, 2011 5:21 PM in response to blist

I see the same issue.


Changes that didn't help:

Installing latest Xquartz

Using iTerm instead of Terminal.app


Changes that seem to have helped

Using 'ssh -Y' rather than 'ssh -X'

Don't tunnel the X connection through the ssh link (i.e. set DISPLAY on remote machine and xhost+ locally)


Both modifications have security implications so use with care.

Aug 26, 2011 6:02 AM in response to blist

So I keep googling hoping someone will answer but non did. I actually installed virtualbox and have Xubuntu running then SSH and everything works fine 😟


So long story short - I keep googling and came to some forums post about Write failed: Broken pipeand apparently this could be because some logging issue from syslogd. You can do something to the com.apple.syslogd.plist as seen here http://dans.im/blog/archives/8 What I did was just move the whole file to the trash can. I think the ssh connection stop dropping now.

May 12, 2014 11:37 AM in response to kr4m17

Thanks this worked for me!

kr4m17 wrote:


Okay. So this was driving me absolutely nuts!!! I am a network admin and I purchased a new MacBook and I couldn't keep an SSH session alive for more than like 10 seconds without getting a broken pipe to any of about a thousand devices I have access to.


I have tried a million things and I FINALLY fixed this. I hope this helps everyone else out there with this problem that couldn't find a solution. I changed my client side (MacOS X) SSH keepalive to an insanely high number. Seems to have done the trick. It also seems to have fixed connectivity problems between other protocols as weel, such as RDP. I do not use RDP as frequently but I was having connectivity problems there as well that seem to have been rectified.


I hope this helps!


sudo sysctl -w net.inet.tcp.always_keepalive=xx


In my case, sudo sysctl -w net.inet.tcp.always_keepalive=9999

Nov 19, 2011 3:21 PM in response to larrycz

I do not have a /etc/sysctl.conf on my Lion nor my Snow Leopard system.


Are you saying that your /etc/sysctl.conf was changed?


Or that the default values for net.inet.tcp.keepidle and net.inet.tcp.keepintvl were too small without a /etc/sysctl.conf file.


I found I could examine my sysctl values using


sysctl -a | grep tcp.keep

net.inet.tcp.keepidle: 7200000

net.inet.tcp.keepintvl: 75000


NOTE: I get the same values for both Lion and Snow Leopard.


All I'm asking is how your system got different values. If you had a /etc/sysctl.conf file that got changed that would explain it.


No matter what, it would be useful for anyone experiencing ssh disconnects to check their net.inet.tcp.keepidle and net.inet.tcp.keepintvl values.

Feb 23, 2012 12:04 PM in response to Cornelius58

Ditto with the re-install. I had to re-install Lion after a failed update to 10.7.3. Previously, I had consistent problems with an SSH connection locking up and later dumping with a broken pipe on some remote servers after sitting with no use for more than 10 minutes. Since then, the Dreamhost servers I connect to no longer exhibit this behavior. Connections to an EC2 instance on AWS, however, still has the same problem.


Furthermore, this was a clean re-install with cherry-picked files copies over via Migration Assistant and Time Machine (not a clean restore directly from TM).

Dec 13, 2012 5:19 PM in response to blist

Okay. So this was driving me absolutely nuts!!! I am a network admin and I purchased a new MacBook and I couldn't keep an SSH session alive for more than like 10 seconds without getting a broken pipe to any of about a thousand devices I have access to.


I have tried a million things and I FINALLY fixed this. I hope this helps everyone else out there with this problem that couldn't find a solution. I changed my client side (MacOS X) SSH keepalive to an insanely high number. Seems to have done the trick. It also seems to have fixed connectivity problems between other protocols as weel, such as RDP. I do not use RDP as frequently but I was having connectivity problems there as well that seem to have been rectified.


I hope this helps!


sudo sysctl -w net.inet.tcp.always_keepalive=xx


In my case, sudo sysctl -w net.inet.tcp.always_keepalive=9999

Aug 17, 2011 8:36 AM in response to blist

Hello,


I too am having the same issue, Write failed: Broken pipe on my ssh connections independent of server. This only happening since I upgraded to Lion, at first I thought it was my Internet Connection acting up, but my colleague here noticed the same thing only after upgrading to Lion everyone else still using Snow Leopard is fine.


I have just upgraded to 10.7.1 and still happening.


I also have under .ssh two files:


config and ssh_config with the contents:


Host *

ServerAliveInterval 120

ServerAliveCountMax 3


I have used just the file config on Snow Leopard and tried to use ssh_config in Lion to see if it resolved the issue but nothing changed...


P.S. - I'm using iTerm2 and was using it with Snow Leopard as well,. my friend just uses the Terminal that comes with OSX.


Thanks for any help on this.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

ssh connections dropping

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.