I'm using Mac to ssh and scp to multiple servers (after I VPN into my company's network from my Mac at home).

I can ssh from Mac via VPN to servers (I call them server A, B, and C), all the time without any problem, no broken pipe, no idle, no kicked out, etc. Based on this, I assume my Mac ssh settings are okay, and server A/B/C settings are also okay for me to ssh in (via VPN) all the time.

After I ssh from Mac via VPN to any of A/B/C, and then scp from any of A/B/C to any of A/B/C without any problem, no matter how big the files are. Based on this, I assume settings on servers A/B/C have are okay.

However, sometimes, I have scp problem, but not always. My usual working style is like this: after VPN is connected, I have a terminal X that ssh into A all the time, another terminal Y scp files to A from occasionally. Although X ssh is always connected, Y may be able to scp files to A in the morning, but may not be able to do so in the afternoon, with errors like:

packet_write_wait: Connection to 192.168.xxx.xxx port 22: Broken pipe

Once it gets the kind of "Broken pipe", it won't be able to scp for hours. I then usually switch to scp to B (and do scp from B to A if A is my final destination). This switch usually works for a day. Next day or so, I may be able to scp to A again, particularly when files are small (because 81920 bytes of file will be transferred before pipe gets broken).

I have edited ~/.ssh/config in my Mac with

Host *
ServerAliveInterval 30
ServerAliveCountMax 5
TCPKeepAlive yes

and /etc/ssh/sshd_config on A/B/C with

ServerAliveInterval 120
ClientAliveInterval 600
ClientAliveCountMax 0

However this does not work.

How can I fix the problem?

  • Dealing with local vpn/routing problems /bugs is most probably out of topic here. Nevertheless there is zero technical detail about that in the question. Talk with your local corporte help desk, we won't guess your corporate side WAN problems – Rui F Ribeiro Mar 3 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.