Connecting to remote guix daemon with encrypted SSH key fails

  • Open
  • quality assurance status badge
Details
2 participants
  • Arun Isaac
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Arun Isaac
Severity
normal
A
A
Arun Isaac wrote on 15 Apr 2022 13:09
(address . bug-guix@gnu.org)
87pmli1u3e.fsf@systemreboot.net
I have an SSH key encrypted with a passphrase. When I try connecting to
a remote guix daemon with that encrypted SSH key, it fails with the
following error message.

Toggle snippet (5 lines)
$ GUIX_DAEMON_SOCKET=ssh://foo guix build -v3 hello
guix build: error: SSH authentication failed for 'foo': Access
denied for 'publickey'. Authentication that can continue: publickey

I expected some kind of prompt asking me for the passphrase, but did not
get any. The same command works if I set up ssh-agent and add the
relevant key to it.
M
M
Maxim Cournoyer wrote on 8 Jun 2022 22:30
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 54950@debbugs.gnu.org)
87a6amkie3.fsf@gmail.com
Hi,

Arun Isaac <arunisaac@systemreboot.net> writes:

Toggle quote (12 lines)
> I have an SSH key encrypted with a passphrase. When I try connecting to
> a remote guix daemon with that encrypted SSH key, it fails with the
> following error message.
>
> $ GUIX_DAEMON_SOCKET=ssh://foo guix build -v3 hello
> guix build: error: SSH authentication failed for 'foo': Access
> denied for 'publickey'. Authentication that can continue: publickey
>
> I expected some kind of prompt asking me for the passphrase, but did not
> get any. The same command works if I set up ssh-agent and add the
> relevant key to it.

I suspect this is due to changes in OpenSSH *client* that now refuse
older RSA keys for security reasons.

Could you retry with the following option: 'StrictHostKeyChecking no'
applied to the host in your ~/.ssh/config?

If that's indeed the problem, you'll want to upgrade your key to
something more modern like ed25519.

I hope that helps,

Maxim
A
A
Arun Isaac wrote on 15 Jun 2022 08:30
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 54950@debbugs.gnu.org)
87sfo630c3.fsf@systemreboot.net
Hi Maxim,

Toggle quote (3 lines)
> I suspect this is due to changes in OpenSSH *client* that now refuse
> older RSA keys for security reasons.

This doesn't seem to be. Here's why: I have another machine that I ssh
to using an unencrypted RSA key. I am able to connect to the Guix daemon
on that machine without any trouble. What's more, the machine with an
encrypted key, whose Guix daemon I'm unable to connect to, uses an ECDSA
key.

Toggle quote (3 lines)
> Could you retry with the following option: 'StrictHostKeyChecking no'
> applied to the host in your ~/.ssh/config?

Adding 'StrictHostKeyChecking no' makes no difference. The unencrypted
key still works, and the encrypted doesn't.

Cheers!
Arun
M
M
Maxim Cournoyer wrote on 15 Jun 2022 17:46
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 54950@debbugs.gnu.org)
8735g6dj4t.fsf@gmail.com
Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> writes:

Toggle quote (17 lines)
> Hi Maxim,
>
>> I suspect this is due to changes in OpenSSH *client* that now refuse
>> older RSA keys for security reasons.
>
> This doesn't seem to be. Here's why: I have another machine that I ssh
> to using an unencrypted RSA key. I am able to connect to the Guix daemon
> on that machine without any trouble. What's more, the machine with an
> encrypted key, whose Guix daemon I'm unable to connect to, uses an ECDSA
> key.
>
>> Could you retry with the following option: 'StrictHostKeyChecking no'
>> applied to the host in your ~/.ssh/config?
>
> Adding 'StrictHostKeyChecking no' makes no difference. The unencrypted
> key still works, and the encrypted doesn't.

Thanks for checking. Other things to try:

Kill pinentry, which is potentially waiting for the passphrase on the
wrong X11 display or tty, for example if you accessed the machine via
SSH:

killall pinentry

I don't know which ssh agent you use; I use the 'gpg-agent' provided by
GnuPG. info '(gnupg) Common Problems' has this:

* SSH hangs while a popping up pinentry was expected

SSH has no way to tell the gpg-agent what terminal or X display it
is running on. So when remotely logging into a box where a
gpg-agent with SSH support is running, the pinentry will get popped
up on whatever display the gpg-agent has been started. To solve
this problem you may issue the command

echo UPDATESTARTUPTTY | gpg-connect-agent

and the next pinentry will pop up on your display or screen.
However, you need to kill the running pinentry first because only
one pinentry may be running at once. If you plan to use ssh on a
new display you should issue the above command before invoking ssh
or any other service making use of ssh.

It seems this gotcha would also apply to other SSH agents. I've had
this problem in the past, when SSH'in to a remote machine that had a
graphical session running, and killing the running pinentry and issuing
the above 'echo UPDATESTARTUPTTY | gpg-connect-agent' command did the
trick.

Let me know if this helps.

Maxim
A
A
Arun Isaac wrote on 16 Jun 2022 08:34
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 54950@debbugs.gnu.org)
87ilp12k21.fsf@systemreboot.net
Hi Maxim,

I normally use neither OpenSSH's ssh-agent nor gpg-agent's ssh-agent
feature. But, when I do, it works. I didn't run into any pinentry issues
like you described. But, that's only because a passphrase entry is not
required at the time of `guix build'. Passphrase entry is required only
at the time of `ssh-add' when I am adding the key to the ssh-agent. Just
to be clear, here are the exact steps I used to set up gpg-agent.

Enable gpg's ssh-agent feature

$ echo use-agent >> ~/.gnupg/gpg.conf
$ echo enable-ssh-support >> ~/.gnupg/gpg-agent.conf

pkill and restart gpg-agent (command not shown). Then, add the key to
gpg's ssh-agent. A passphrase is prompted at this point.

$ ssh-add ~/.ssh/id_ecdsa

guix build with remote daemon. A passphrase is not prompted at this
point because it was already added into the ssh-agent in the last step.

$ SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh
GUIX_DAEMON_SOCKET=ssh://foo guix build -v3 hello

So, with an ssh-agent, guix build on a remote daemon works. But, I'd
like it to work without an ssh-agent. Is that possible?

Regards,
Arun
M
M
Maxim Cournoyer wrote on 16 Jun 2022 16:01
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 54950@debbugs.gnu.org)
87a6acd7we.fsf@gmail.com
Hello Arun,

Arun Isaac <arunisaac@systemreboot.net> writes:

Toggle quote (3 lines)
> So, with an ssh-agent, guix build on a remote daemon works. But, I'd
> like it to work without an ssh-agent. Is that possible?

I've re-read the original issue and now I have a better understanding of
it; the manual mentions GUIX_DAEMON_SOCKET is handled via the Guile-SSH
library. I'm curious as to how SSH clients typically trigger 'pinentry'
to prompt; perhaps Guile-SSH is lacking some feature here.

I hope someone in the know can tip in! In the meantime, you've already
found a workaround (the use of an SSH agent).

Thanks,

Maxim
A
A
Arun Isaac wrote on 17 Jun 2022 08:52
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 54950@debbugs.gnu.org)
87fsk33hob.fsf@systemreboot.net
Hi Maxim,

Toggle quote (3 lines)
> I'm curious as to how SSH clients typically trigger 'pinentry' to
> prompt; perhaps Guile-SSH is lacking some feature here.

Exactly my point! :-)

Toggle quote (3 lines)
> I hope someone in the know can tip in! In the meantime, you've already
> found a workaround (the use of an SSH agent).

Yup.

Thanks,
Arun
?