From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by sourceware.org (Postfix) with ESMTPS id 8DF25385DC0A for ; Thu, 23 Apr 2020 20:05:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8DF25385DC0A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=anrdaemon@yandex.ru Received: from mxback22g.mail.yandex.net (mxback22g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:322]) by forward100o.mail.yandex.net (Yandex) with ESMTP id 6F50B4AC1538; Thu, 23 Apr 2020 23:05:01 +0300 (MSK) Received: from iva8-6403930b9beb.qloud-c.yandex.net (iva8-6403930b9beb.qloud-c.yandex.net [2a02:6b8:c0c:2c9a:0:640:6403:930b]) by mxback22g.mail.yandex.net (mxback/Yandex) with ESMTP id eRyXWpftSF-51DSeP7C; Thu, 23 Apr 2020 23:05:01 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1587672301; bh=yakfh6C/c3pTjtOjrG7VVp0GjIK758EHc3mFcrN97Lc=; h=In-Reply-To:Subject:To:Reply-To:From:Message-ID:References:Date; b=VqAcUceAMA1KgTFO/5oE+tkhC05tO1tUE2tAjLyUXXhE8VwJKsHU4o7GUhwaXpKsA kHJwwdtRzWFIa88fFD9yFszEHGaGzRAzTol+eZIZy41pbfhJ2Qbt682CLabLyosEu8 mq/hKfForW50fAOZs1XI55ObzAyu8MAXI0vtSieU= Authentication-Results: mxback22g.mail.yandex.net; dkim=pass header.i=@yandex.ru Received: by iva8-6403930b9beb.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id pVKeALesNh-50W4kbDE; Thu, 23 Apr 2020 23:05:00 +0300 (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (Client certificate not present) Received: from [192.168.1.10] (HELO daemon2.darkdragon.lan) by daemon2 (Office Mail Server 0.8.12 build 08053101) with SMTP; Thu, 23 Apr 2020 20:02:03 -0000 Date: Thu, 23 Apr 2020 23:02:02 +0300 From: Andrey Repin X-Mailer: The Bat! (v6.8.8) Home Reply-To: cygwin@cygwin.com X-Priority: 3 (Normal) Message-ID: <373832437.20200423230202@yandex.ru> To: Chris Rodgers , cygwin@cygwin.com Subject: Re: ssh-pageant In-Reply-To: <5f24168f-61d7-848b-677d-bf0d5aea303a@cam.ac.uk> References: <5f24168f-61d7-848b-677d-bf0d5aea303a@cam.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_2, KAM_THEBAT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Apr 2020 20:05:09 -0000 Greetings, Chris Rodgers! > I find the ssh-pageant package helpful to enable cygwin ssh to interact > seamlessly with PuTTY's Pageant SSH agent. One small issue is that after > installing, one has to add the lines: >> |# ssh-pageant eval $(/usr/bin/ssh-pageant -r -a >> "/tmp/.ssh-pageant-$USERNAME")| > (see https://github.com/cuviper/ssh-pageant) > to .bashrc for each user. > Would it be acceptable to update the ssh-pageant package to add a file > /etc/profile.d/ssh-pageant.sh that does this automatically? It's not that simple. You can't blindly restart agent every time you wish without notifying other programs, `--reuse` is a very bad idea and there's no easy way to set/change an environment variable globally for an entire user session. > Or is there another preferred way to do this, e.g. a postinstall script? > I'd be happy to draft a script file for review. Just create a script for yourself and amend your own .bashrc accordingly. I do it this way: 1. Add ----- 8< ----- 8< ----- 8< ----- 8< ----- # Import ssh-pageant settings test -f "$HOME/.ssh/agent" && . "$HOME/.ssh/agent" ----- >8 ----- >8 ----- >8 ----- >8 ----- near the end of .bashrc 2. Create a script `$HOME/profile.d/ssh-pageant.sh` ----- 8< ----- 8< ----- 8< ----- 8< ----- #!/bin/sh [ -x /usr/bin/ssh-pageant ] || return _agent="$HOME/.ssh/agent" eval set -- $( getopt --shell=sh -o 'k' -- "$@" ) test -f "$_agent" && . "$_agent" if [ "$SSH_PAGEANT_PID" ]; then if test "$1" = "-k"; then /usr/bin/ssh-pageant -qk 2> /dev/null fi if ! kill -0 "$SSH_PAGEANT_PID" 2> /dev/null; then # Reap dead agent's socket rm "$SSH_AUTH_SOCK" "$_agent" 2> /dev/null unset SSH_AUTH_SOCK SSH_PAGEANT_PID fi fi test "$1" = "-k" && exit test "$SSH_PAGEANT_PID" && exit socket="$( mktemp -u /var/run/ssh-XXXXXXXX )" eval $( cygdrop -- /usr/bin/ssh-pageant -qsa "$socket" | tee "$_agent" ) # Remove empty settings file (agent failed to start). test -s "$_agent" || rm "$_agent" ----- >8 ----- >8 ----- >8 ----- >8 ----- 3. Create login job to run scripts from ~/profile.d/ on user login. 4. If you need agent settings in a different script, that may be run outside normal terminal/shell workflow, just add ----- 8< ----- 8< ----- 8< ----- 8< ----- test -f "$HOME/.ssh/agent" && . "$HOME/.ssh/agent" ----- >8 ----- >8 ----- >8 ----- >8 ----- near the top. 5. Don't forget to `ssh-pageant.sh -k` before running Cygwin setup. -- With best regards, Andrey Repin Thursday, April 23, 2020 21:28:24 Sorry for my terrible english...