| delorie.com/archives/browse.cgi | search |
| 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.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 AT yandex DOT ru | |
| 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 | |
| Date: | Thu, 23 Apr 2020 23:02:02 +0300 |
| From: | Andrey Repin <anrdaemon AT yandex DOT ru> |
| X-Mailer: | The Bat! (v6.8.8) Home |
| X-Priority: | 3 (Normal) |
| Message-ID: | <373832437.20200423230202@yandex.ru> |
| To: | Chris Rodgers <ctr28 AT cam DOT ac DOT uk>, cygwin AT cygwin DOT com |
| Subject: | Re: ssh-pageant |
| In-Reply-To: | <5f24168f-61d7-848b-677d-bf0d5aea303a@cam.ac.uk> |
| References: | <5f24168f-61d7-848b-677d-bf0d5aea303a AT cam DOT ac DOT uk> |
| MIME-Version: | 1.0 |
| 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 AT cygwin DOT com |
| X-Mailman-Version: | 2.1.29 |
| List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
| List-Unsubscribe: | <http://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: | <http://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 AT cygwin DOT com |
| Sender: | "Cygwin" <cygwin-bounces AT cygwin DOT com> |
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)
> <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...
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |