[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnupg-users
Subject:    Using gpg-agent as ssh-agent on Windows with MSYS
From:       Sebastien <lechtitseb () gmail ! com>
Date:       2017-11-29 20:50:54
Message-ID: CALPZHjNXo-2WbepwAPb76HodaPdY2i3F3MMrFfFW8oZdpqzPFw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello,

I think I'm currently facing the issue described in
https://lists.gnupg.org/pipermail/gnupg-users/2016-September/056771.html
(sorry, couldn't find how to just reply to that thread).

I'm using GnuPG, gpg and gpg-agent in my Windows Git bash environment
(MSYS) (on Windows 10 x64). I like having everything in there for ease of
use and portability.

I'd like to know if this is just a known issue/limitation with a known
workaround or if it's just not supported?

Some more background about what I've configured/tried:

Just starting gpg-agent with gpg-connect-agent/bye doesn't work for me, it
always gives the following error:
$ gpg-connect-agent /bye
ERR 67109139 Unknown IPC command <GPG Agent>

I could work around that error using: MSYS_NO_PATHCONV=1 gpg-connect-agent
--homedir $GNUPGHOME_WIN /bye

Where $GNUPGHOME_WIN just contains the Windows style path to my gnupg
folder (in my case c:\CloudStation\Configuration\SebHome\.gnupg).
Effectively like that MSYS doesn't perform path conversions and
gpg-connect-agent / gpg-agent seem to receive the correct path.

In my ~/.gnupg folder I then do find those files:
gnupg_spawn_agent_sentinel.lock
S.gpg-agent
...
S.gpg-agent.ssh

And the agent seems to be running:
$ gpg-agent
gpg-agent[14380]: gpg-agent running and available

Unfortunately if I execute ssh-add -L, I get:
$ ssh-add -L
Error connecting to agent: Bad file descriptor

Here's the part of my bash profile with comments about things I've tried
and that didn't help:

# GnuPG home
export GPG4WIN_HOME=$TOOLS_HOME/Gpg4Win_3.0.1
export GPG_HOME=$GPG4WIN_HOME/GnuPG
export KLEOPATRA_HOME=$GPG4WIN_HOME/Gpg4win

append_to_path $GPG_HOME
append_to_path $GPG_HOME/bin
append_to_path $KLEOPATRA_HOME/bin_64
append_to_path $KLEOPATRA_HOME/bin

# where it puts its files and looks for its configuration
export GNUPGHOME=$HOME/.gnupg

# path conversion ref: https://stackoverflow.com/questions/13701218/windows-
path-to-posix-path-conversion-in-bash
export GNUPGHOME_WIN=$(eval "echo $GNUPGHOME" | sed -e 's/^\///' -e
's/\//\\/g' -e 's/^./\0:/')

# create the home folder otherwise gpg will complain
mkdir -p `echo $GNUPGHOME`
alias gpg='gpg.exe'
alias pgp='gpg'
alias kleopatra='kleopatra.exe'

# Start the gpg-agent (daemon)
# Eliminate path conversion issues for that specific command
# Reference: https://stackoverflow.com/questions/7250130/how-to-stop-
mingw-and-msys-from-mangling-path-names-given-at-the-command-line

# daemon that will manage the gpg keys and allow to perform ssh auth
#eval $( MSYS_NO_PATHCONV=1 gpg-agent --daemon --enable-ssh-support
--enable-putty-support  --homedir $GNUPGHOME_WIN ) &

# Ref: https://incenp.org/notes/2015/gnupg-for-ssh-authentication.html
# Ref: https://www.gnupg.org/documentation/manuals/gnupg/
Invoking-gpg_002dconnect_002dagent.html
MSYS_NO_PATHCONV=1 gpg-connect-agent --homedir $GNUPGHOME_WIN /bye

# Configure SSH_AUTH_SOCK (so that ssh-add can contact the gpg-agent)
#export GPG_AGENT_PID=$$
#export GPG_AUTH_SOCK=$(echo $HOME/.gnupg/S.gpg-agent.ssh)
#export SSH_AUTH_SOCK=$GPG_AUTH_SOCK

# with Win path (not helping)
#export GPG_AUTH_SOCK=$(echo $GNUPGHOME_WIN/S.gpg-agent.ssh)
#export SSH_AUTH_SOCK=$GPG_AUTH_SOCK

#export SSH_ENV="$HOME/.ssh/environment"


Any help would really be appreciated!

[Attachment #5 (text/html)]

<div dir="ltr"><div>Hello,</div><div><br></div><div>I think I&#39;m currently facing \
the issue described in <a \
href="https://lists.gnupg.org/pipermail/gnupg-users/2016-September/056771.html">https://lists.gnupg.org/pipermail/gnupg-users/2016-September/056771.html</a> \
(sorry, couldn&#39;t find how to just reply to that \
thread).</div><div><br></div><div>I&#39;m using GnuPG, gpg and gpg-agent in my \
Windows Git bash environment (MSYS) (on Windows 10 x64). I like having everything in \
there for ease of use and portability.<br></div><div><br></div><div>I&#39;d like to \
know if this is just a known issue/limitation with a known workaround or if it&#39;s \
just not supported?</div><div><br></div><div>Some more background about what I&#39;ve \
configured/tried:</div><div><br></div><div><div style="font-size:12.8px">Just \
starting gpg-agent with gpg-connect-agent/bye doesn&#39;t work for me, it always \
gives the following error:</div><div style="font-size:12.8px"><span \
style="font-size:12.8px">$ gpg-connect-agent /bye</span><br></div><div \
style="font-size:12.8px"><div>ERR 67109139 Unknown IPC command &lt;GPG \
Agent&gt;</div><div><br></div><div><span style="font-size:12.8px">I could work around \
that error using:  MSYS_NO_PATHCONV=1 gpg-connect-agent --homedir $GNUPGHOME_WIN \
/bye</span><br></div></div><div style="font-size:12.8px"><br></div><div \
style="font-size:12.8px">Where $GNUPGHOME_WIN just contains the Windows style path to \
my gnupg folder (in my case c:\CloudStation\Configuration\<wbr>SebHome\.gnupg). \
Effectively like that MSYS doesn&#39;t perform path conversions and gpg-connect-agent \
/ gpg-agent seem to receive the correct path.</div><div \
style="font-size:12.8px"><br></div><div style="font-size:12.8px">In my ~/.gnupg \
folder I then do find those files:</div><div \
style="font-size:12.8px">gnupg_spawn_agent_sentinel.<wbr>lock<br></div><div \
style="font-size:12.8px">S.gpg-agent</div><div style="font-size:12.8px">...</div><div \
style="font-size:12.8px">S.gpg-agent.ssh</div><div \
style="font-size:12.8px"><br></div><div style="font-size:12.8px">And the agent seems \
to be running:</div><div style="font-size:12.8px"><div>$ \
gpg-agent</div><div>gpg-agent[14380]: gpg-agent running and available</div></div><div \
style="font-size:12.8px"><br></div><div style="font-size:12.8px">Unfortunately if I \
execute ssh-add -L, I get:</div><div style="font-size:12.8px">$ ssh-add \
-L<br></div><div style="font-size:12.8px">Error connecting to agent: Bad file \
descriptor</div><div style="font-size:12.8px"><br></div><div \
style="font-size:12.8px"><span style="font-size:12.8px">Here&#39;s the part of my \
bash profile with comments about things I&#39;ve tried and that didn&#39;t \
help:</span><br></div><div style="font-size:12.8px"><br></div><blockquote \
style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px"><div># GnuPG \
home</div><div>export GPG4WIN_HOME=$TOOLS_HOME/<wbr>Gpg4Win_3.0.1</div><div>export \
GPG_HOME=$GPG4WIN_HOME/GnuPG</div><div>export \
KLEOPATRA_HOME=$GPG4WIN_HOME/<wbr>Gpg4win</div><div><br></div><div>append_to_path \
$GPG_HOME</div><div>append_to_path $GPG_HOME/bin</div><div>append_to_path \
$KLEOPATRA_HOME/bin_64</div><div>append_to_path \
$KLEOPATRA_HOME/bin</div><div><br></div><div># where it puts its files and looks for \
its configuration</div><div>export \
GNUPGHOME=$HOME/.gnupg</div><div><div><br></div><div># path conversion ref:  <a \
href="https://stackoverflow.com/questions/13701218/windows-path-to-posix-path-conversion-in-bash" \
target="_blank">https://stackoverflow.com/<wbr>questions/13701218/windows-<wbr>path-to-posix-path-conversion-<wbr>in-bash</a></div></div><div>export \
GNUPGHOME_WIN=$(eval &quot;echo $GNUPGHOME&quot; | sed -e &#39;s/^\///&#39; -e \
&#39;s/\//\\/g&#39; -e &#39;s/^./\0:/&#39;)</div><div><br></div><div># create the \
home folder otherwise gpg will complain</div><div>mkdir -p `echo \
$GNUPGHOME`</div><div>alias gpg=&#39;gpg.exe&#39;</div><div>alias \
pgp=&#39;gpg&#39;</div><div>alias \
kleopatra=&#39;kleopatra.exe&#39;</div><div><br></div><div># Start the gpg-agent \
(daemon)<br></div><div># Eliminate path conversion issues for that specific \
command</div><div># Reference:  <a \
href="https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line" \
target="_blank">https://stackoverflow.com/<wbr>questions/7250130/how-to-stop-<wbr>ming \
w-and-msys-from-mangling-<wbr>path-names-given-at-the-<wbr>command-line</a></div><div><br></div><div># \
daemon that will manage the gpg keys and allow to perform ssh auth</div><div>#eval $( \
MSYS_NO_PATHCONV=1 gpg-agent --daemon --enable-ssh-support --enable-putty-support   \
--homedir $GNUPGHOME_WIN ) &amp;</div><div><br></div><div># Ref:  <a \
href="https://incenp.org/notes/2015/gnupg-for-ssh-authentication.html" \
target="_blank">https://incenp.org/notes/2015/<wbr>gnupg-for-ssh-authentication.<wbr>html</a></div><div># \
Ref:  <a href="https://www.gnupg.org/documentation/manuals/gnupg/Invoking-gpg_002dconnect_002dagent.html" \
target="_blank">https://www.gnupg.org/<wbr>documentation/manuals/gnupg/<wbr>Invoking-gpg_002dconnect_<wbr>002dagent.html</a></div><div>MSYS_NO_PATHCONV=1 \
gpg-connect-agent --homedir $GNUPGHOME_WIN /bye</div><div><br></div><div># Configure \
SSH_AUTH_SOCK (so that ssh-add can contact the gpg-agent)</div><div>#export \
GPG_AGENT_PID=$$</div><div>#export GPG_AUTH_SOCK=$(echo \
$HOME/.gnupg/S.gpg-agent.ssh)</div><div>#export \
SSH_AUTH_SOCK=$GPG_AUTH_SOCK</div><div><br></div><div># with Win path (not \
helping)</div><div>#export GPG_AUTH_SOCK=$(echo \
$GNUPGHOME_WIN/S.gpg-agent.<wbr>ssh)</div><div>#export \
SSH_AUTH_SOCK=$GPG_AUTH_SOCK</div><div><br></div><div>#export \
SSH_ENV=&quot;$HOME/.ssh/<wbr>environment&quot;</div></blockquote><div \
style="font-size:12.8px"><br></div><div style="font-size:12.8px">Any help would \
really be appreciated!</div></div></div>



_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic