delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/04/04/03:36:11

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 197DB3858C53
Authentication-Results: sourceware.org;
dmarc=pass (p=none dis=none) header.from=yandex.ru
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru
X-Yandex-Fwd: 2
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
t=1649057701; bh=hmc88S6MgbtPB5XH0SQiR0ijrv0ERXMmIhrJvrccu3I=;
h=In-Reply-To:Subject:To:From:Message-ID:References:Date:Reply-To;
b=tKaVWlD8IQ+zfyvUt5epXuLh57urL+7rFGxOyMsCJpfdMLT+sh3aihNTVAarMVIMg
F1YMLMRFGe0ZQw4VB+8FSsF4YCTPqXfFgtchKFOyk2YLLnCqH2J+HwSXW8eV4wb4tv
uJ4HrKJx506I8mpFPAkGEKGE+Dkn2n7ntUo8nuC4=
Authentication-Results: vla5-10833e9cc57f.qloud-c.yandex.net;
dkim=pass header.i=@yandex.ru
Date: Mon, 4 Apr 2022 10:25:06 +0300
From: Andrey Repin <anrdaemon AT yandex DOT ru>
X-Mailer: The Bat! (v9.3.4) Professional
Message-ID: <1478129170.20220404102506@yandex.ru>
To: Jim Garrison via Cygwin <jhg AT acm DOT org>, cygwin AT cygwin DOT com
Subject: Re: OpenSSH 8.9p1-1 Connects successfully but then hangs - Killing
ssh-agent resolves the issue
In-Reply-To: <3ed89752-9676-a668-f63c-1a9b7662d7b5@jhmg.net>
References: <3ed89752-9676-a668-f63c-1a9b7662d7b5 AT jhmg DOT net>
MIME-Version: 1.0
X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_THEBAT,
NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE,
XM_LIGHT_HEAVY autolearn=no autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

Greetings, Jim Garrison via Cygwin!

Replying to the first post to reduce quoting, but I did read the entire thread.

> My Cygwin ssh client stopped working... It would successfully connect to
> the remote (Debian) host but then hang without displaying the command
> prompt.  See debug output attached, as well as cygcheck output.

> I decided to run setup to see if there was a newer version of openssh.
> In preparation for that I always terminate all Cygwin processes because
> they will interfere with the update.  I killed the ssh-agent process and
> on a whim decided to try connecting again.  This time it worked.

> This would seem to indicate something in ssh-agent is interfering with
> the connection.  There are no credentials loaded into ssh-agent.

I've encountered similar issue with ssh-pageant myself.
The explanation (as I see it) is this:
At certain point in its lifetime, the agent gets stuck <somewhere> and cease
to respond to the requests.
SSH attempting to contact the hung agent, the connection thread responds but
internal storage is somehow locked and never return any usable info on which
the client could meaningfully act. Since neither agent, nor SSH have any
guarding code against slow responses in this place, entire system hangs
indefinitely.

This is how the problem is observed. The following is a pure guesswork (with a
workaround).

I'm only exclusively observing this issue on my notebook. My guess is when it
awakes from hibernation, some internal state is not managed well. The delay in
agent response gets increasingly larger until it reaches the point of
intolerability. I've made a workaround like the following:

_check_agent() {
  test -f "$HOME/.ssh/agent" && . "$HOME/.ssh/agent" > /dev/null
  ssh-add -l > /dev/null 2>&1 &
  sleep 1
  if kill -0 $! 2> /dev/null; then
    echo "$( basename "$0" ): ssh-add: the agent is hung, unable to continue" >&2
    exit 1
  fi

  if ! wait $!; then
    echo "$( basename "$0" ): ssh-add: no identities or unable to contact the agent" >&2
    exit 2
  fi
}

What it does is:
1. Run a command to list available keys, detached.
2. Wait a second to let the command complete, if all goes well.
3. Test if a listing command is still around. If it does, assume hung agent
and report an error.
4. Also report an error if no keys are registered with agent or agent is dead.


-- 
With best regards,
Andrey Repin
Monday, April 4, 2022 9:16:49

Sorry for my terrible english...


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019