Mac os ssh broken pipe

SSH Broken Pipe fix (Mac OS X)

Hi!
There was a problem with my ssh connection with AzureVM. It was a suddenly disconnect with «Broken Pipe» error.
To fix it, on your mac do:

emacs (or vim/vi/nano/etc)

And then, write this:

Now it is fixed ^_^

Written by Alexey Slaykovsky

Remote Access to IPython Notebooks via SSH

Multiple SSH keys for different accounts on Github or Gitlab

Access EC2 Linux box over ssh without .pem file

3 Responses

Thanks for the fix. Do you have understanding to provide a little background on why these settings fix the problem?

edit: after a little research:

ServerAliveInterval 120 means «If there is no activity for 120 seconds on the connection, send a request to the server, requesting a response.» I believe this is useful because some servers are configured to drop inactive ssh sessions. This keeps the connection active so that doesn’t happen.

TCPKeepAlive no means «do not send keepalive messages to the server». If the converse, TCPKeepAlive yes , were set, then the client sends keepalive messages to the server and requires a response in order to maintain its end of the connection. This will detect if the server goes down, reboots, etc. The trouble with this is that if the connection between the client and server is broken for a brief period of time, this will cause the keepalive messages to fail, and the client will end the connection with «broken pipe».

Setting TCPKeepAlive no tells the client to just assume the connection is still good until proven otherwise by a user request, meaning that temporary connection breakages while your ssh term is sitting idle in the background won’t kill the connection.

Источник

Question: Q: SSH broken after update.

A while back there was an update (10.15.5 I think). After that my ssh

has been broken. Now when I try to open an ssh connection I get

«client_loop: send disconnect: Broken pipe». the odd part is that it is

not all the time. It happens about 75% of the time, but usually if I am

able to connect I will get disconnected within a few minutes. I’m wonder

if it has anything to do with the relocated files and the ssh_config.

Posted on Nov 12, 2020 3:39 PM

All replies

Loading page content

Page content loaded

Thanks for asking the Apple Support Communities for help with SSH.

It sounds like you have issues connecting with another device. Please ensure everything is set up as described in these three help articles:

Thanks and have a wonderful day.

Nov 18, 2020 7:33 PM

Yes it broke after updating. The Terminal app built into the Mac OS seems to be broken after the Catalina update. When I try to make an ssh connection I get «client_loop: send disconnect: Broken pipe». I installed the Termius app from the app store. It works perfectly fine. It seems the issue is with the Terminal app itself. The problem for me is most of my other apps that have SSH integration, only integrate with the build in terminal so they are all broken.

Читайте также:  Bootnxt windows 10 что это

Nov 23, 2020 3:08 PM

F In response to Eric

This does not seems to have anything to do with an issue connecting to another devices. I am connecting to the same ssh server in from the same laptop at the same time with each of the terminal clients. Termius works, Terminal does not.

Источник

Что означает сообщение Broken pipe в сеансе SSH?

Иногда мой сеанс SSH отключается с сообщением Write failed: Broken pipe . Что это значит? И как я могу открыть сеанс?

Я знаю о screen , но это не тот ответ, который я ищу. Я думаю, что это вариант конфигурации sshd .

6 ответов

Возможно, ваш сервер закрывает слишком длинные простоя. Вы можете обновить либо ваш клиент ( ServerAliveInterval ), либо ваш сервер ( ClientAliveInterval )

Для обновления вашего сервера (и перезапустите sshd )

Или клиентская сторона:

Альтернативным решением было бы использовать mosh — мобильную оболочку . > . В отличие от ssh, он подключается через UDP и поддерживает роуминг. Вы можете начать свою сессию дома, приостановить работу своего ноутбука, взять его на работу /друзей /где бы вы ни располагали интернет, отказаться от своего ноутбука и продолжать работать так, как будто ничего не произошло. Это особенно полезно, если вы находитесь в паршивом интернет-соединении: он показывает мгновенную обратную связь, если ваши нажатия клавиш не доходят до сервера и постоянно пытается восстановить соединение.

Установка и настройка просты: теперь он включен во все текущие дистрибутивы Linux (плюс несколько не Linux) и координирует инициализацию и аутентификацию сеанса через предыдущее соединение ssh. Поэтому, если вы можете подключиться через ssh [email protected] , вы, скорее всего, сможете подключиться к mosh, просто позвонив mosh [email protected] , если пакеты mosh установленный на обоих концах.

Основная причина сбоев подключения заключается в том, что вам нужно добраться до сервера на UDP-порту (диапазон по умолчанию: 60000-61000) для работы mosh. Поэтому, если сервер находится за брандмауэром, вам в основном не повезло, если он не может пробить дыры в нем самостоятельно ( последствия для безопасности ).

Если вы хотите иметь более длительный период соединения, в клиенте добавьте:

ServerAliveCountMax по умолчанию это значение равно 3. Поэтому, когда ServerAliveInterval отправил 3 небольших пакета информации на ваш сервер, он автоматически выйдет из системы. Установка его на 1200 означает, что этот процесс должен произойти по крайней мере 1200 раз. Короче говоря, вы должны быть подключены не менее 30 * 1200 секунд (10 часов).

Обычно это означает, что ваше сетевое (TCP) соединение было сброшено. Например. ваш интернет-провайдер подключил вас или что-то вроде этого.

У меня была та же проблема, но это не так, как ожидалось. Если вы обнаружите, что в той же сети другой сервер пытается использовать тот же IP-адрес, вы столкнетесь с той же проблемой. Чтобы решить эту проблему, вам нужно проверить, есть ли другие серверы, которые используют один и тот же IP-адрес. Это можно сделать с помощью команды arp .

Я использую Debian, поэтому вот пример команд, которые я использую, чтобы определить, действительно ли другой сервер использует один и тот же IP-адрес.

Читайте также:  Total commander android windows

Вы заметите два набора MAC-адреса, используя тот же IP-адрес. Избегайте конфликтов, установив один на другой IP-адрес.

Другая причина для сообщения «Broken Pipe» заключается в том, что другой компьютер пытается использовать тот же IP-адрес, что и ваш хост.

Простой способ проверить, использует ли кто-нибудь другой IP-адрес:

  1. Отключите хост
  2. пинг одного и того же IP-адреса, чтобы узнать, использует ли другой компьютер этот IP-адрес

Чтобы узнать, какие компьютеры находятся в вашей сети, вы можете использовать этот Unix & Заголовок вопроса Linux: Как сделать найти, какие другие компьютеры подключены к локальной сети .

Источник

Fixing Broken Pipe Error With SSH Connection

If you use SSH to connect to remote Linux servers, you’ll notice that if you keep your SSH session inactive for some time and then try to use it again, the SSH session disconnects with an error message like this:

On some systems, it will display ‘Write failed: Broken pipe’ or ‘Connection closed by remote host’.

Let’s see what causes this error and how to go about keeping your SSH connection alive.

Fixing broken pipe error with SSH

As you may have guessed, the SSH connection is closed because of inactivity. There is no set value but it usually around 5 minutes or so.

What you can do to avoid the SSH session disconnection is to send an ‘alive message’ either from the server to client ( ClientAliveInterval ) or from client to server ( ServerAliveInterval ) at certain time interval.

This way, you keep the SSH session alive because there is a communication between the client and server and the server understands that client is still there.

Now, there are two ways to do that. Either you send the alive message from the client to the server or from the server to the client.

  • If you connect to multiple servers via SSH, set it on your machine.
  • If you are a sysadmin and several of users complain about frequent SSH connection disconnect, you may set it on the server.

Method 1: Client side SSH configuration change

Let’s say you want to keep your SSH connection alive with up to 10 minutes (600 seconds) of idle time.

While connecting to the remote Linux system through SSH, you can mention the ServerAliveInterval value like this:

Now, this thing work but manually entering this option each time you connect to the server is tiresome. Why not make it permanent?

I hope you are aware of the SSH config files. On the client side, you can take advantage of it to set certain SSH parameters for specific connections or all of them. I have explained SSH config file in detail here.

First, make sure that you have the ssh config file. If not create it:

It is important to give it the correct file permissions otherwise you’ll have permission denied error while connecting via SSH.

Use the chmod command and add the following file permission to it:

If you’re feeling lazy or don’t want to go in detail, use this command to set the alive interval to 600 seconds (10 minutes):

This will set the ServerAliveInterval value to 10 minutes for all SSH connection you’ll use. Give it a try if you want to.

Читайте также:  Windows для компьютеров apple

If you want to make it more proper, you should add it like this:

Method 2: Server side SSH config change

The SSH config file for the server is usually located at /etc/ssh/sshd_config.

If you open this file, you’ll find two parameters of interest here:

  • ClientAliveInterval : This is the inactivity time period after which the server will send an alive message to the ssh connected client.
  • ClientAliveCountMax : This is the number of attempts the server will make to send the alive message.

Say, you set ClientAliveInterval to 200 seconds and ClientAliveCountMax to 3. This means the server will send alive message after 200 seconds. If there is no activity from the client, it will again send an alive message at 400 seconds. No response/activity from the client and another alive message is sent at 600 seconds. After this (600 seconds) the SSH connection is disconnected.

You can edit the /etc/ssh/sshd_config file in your favorite terminal based text editor like Vim. Look for ClientAliveInterval and ClientAliveCountMax entries. Remove the # key at the beginning of the lines and give them the appropriate value.

Save and exit the file.

Please do not set the SSH connection timeout to several hours. That would be a waste of resources.

I hope this tutorial helped you to fix the broken pipe error issue with SSH connection. Your feedback is welcome.

Источник

Next Spaceship

Driving into future…

How to Solve Broken Pipe Message in SSH Session

Sep 22 nd , 2011 8:55 pm | Comments

Sometimes my SSH session disconnects with a Write failed: Broken pipe message. What does it mean? And how can I keep my session open?

It’s possible that your server closes connections that are idle for too long. You can update either your client (ServerAliveInterval) or your server (ClientAliveInterval).

ServerAliveInterval Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent to the server.
This option applies to protocol version 2 only.

ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.
This option applies to protocol version 2 only.

To update your server (and restart your sshd)

Although you have configured all the above parameters, sometimes the connection just breaks. To solve this problem, I wrote this shell script to automatically restart ssh as soon as it breaks down.

(Replace YOUR_REMOTE_USER and YOUR_REMOTE_IP with the username and ip address of your remote server correspondingly. Replace YOUR_LOCAL_PORT with the local port you want to listen on for proxy.)

If you want to connect to your remote machine via SSH without a password, go to /2011/11/ssh-login-without-password/

Update:

As John replies in the comments, you can also place this line in your

/.ssh/config file ServerAliveCountMax = 120 to make your SSH connection stays alive longer.

Posted by Leon Sep 22 nd , 2011 8:55 pm network

Источник

Оцените статью