yubico-piv-tool: ykcs11: 'agent refused operation' OS X 10.13.6
Hi,
I am aware of #88 featuring @paul-pearce & co, but that does not help and is also partly obsolete because PIV functionality is now built-in to OS X. I have also seen #118, but not much of interest there, partly for the same reasons.
To summarise where I am at:
Basic setup has been done:
yubico-piv-tool -achange-pin
yubico-piv-tool -achange-puk
yubico-piv-tool -k -agenerate -s9c -AECCP384
This:
ssh-add -s/Users/foobar/Work/yubico-piv-tool-1.6.0-mac/lib/libykpiv.dylib
Does not work, it yields agent refused operation.
So then I compiled the latest versions of libressl (2.8.0) and openssh (7.7p1) from scratch, thinking it might be something with the Apple binaries (OS X 10.13.6 ships with OpenSSH_7.6p1 compiled against LibreSSL 2.6.2), but that yields the same agent refused operation, e.g.:
libre/bin/ssh-add -s/Users/foobar/Work/yubico-piv-tool-1.6.0-mac/lib/libykcs11.dylib
I then read about the whitelist, and so I tried this:
libre/bin/ssh-agent -P/Users/foobar/Work/yubico-piv-tool-1.6.0-mac/lib/*
SSH_AUTH_SOCK=/path/to/sock/agent.96574 libre/bin/ssh-add -s/Users/foobar/Work/yubico-piv-tool-1.6.0-mac/lib/libykcs11.dylib
That yields the same errorL
Could not add card “/Users/foobar/Work/yubico-piv-tool-1.6.0-mac/lib/libykcs11.dylib”: agent refused operation
And running ssh-agent in debug (-d) mode doesn’t yield much of interest:
debug2: fd 3 setting O_NONBLOCK
debug3: fd 4 is O_NONBLOCK
debug1: process_message: socket 1 (fd=4) type 20
debug1: process_add_smartcard_key: add /Users/foobar/Work/yubico-piv-tool-1.6.0-mac/lib/libykcs11.dylib
Finally, I should add that for all the tests above, I have also tried the /usr/local/lib trick as mentioned i the previous issues, and that made no difference.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (4 by maintainers)
I would like to report that getting PIV-based SSH authentication working on macOS Monterey has been an absolutely horrendous experience. It took me hours and hours to figure everything out. Here are some of the issues I encountered (as far as I can remember them):
ssh-keygen -D /usr/local/lib/libykcs11.dylibdoes list an RSA key, but that turned out to be the key in slot f9, which is not useable for SSH authentication (why does ssh-keygen list it then?).After all this, I can’t say that I am a satisfied customer. I am aware that Apple likes to move stuff around with every OS upgrade, which is part of the problem here. But Yubico can make the experience infinitely more smooth for their customers by making sure their documentation is up to date. Please!
I chose to generate an RSA key in slot 9c instead of overwriting my ECCP256 key in slot 9a:
I recommend using the CACHED pin policy instead if you’re running remote VSCode sessions over SSH, because it seems to make several connections requiring you to touch the key every time.
After telling ssh-keygen to accept /usr/local/lib/libykcs11.dylib run with the
-Pargument (see this gist and that gist, but see NOTE below), these work:NOTE: It’s better to disable the existing com.openssh.ssh-agent launch agent and make your custom one use
SSH_AUTH_SOCKdirectly. This will avoid having to overrideSSH_AUTH_SOCKwithSSH_AUTH_SOCK_LOCALin various places.I need to add libykcs11.so to the agent because I wanted to avoid having to enter the PIN every time I connect (ykman’s
--pin-policydoesn’t seem to have any effect).But then there’s the issue that you need to remove and add libykcs11.so from/to the agent if the Yubikey was unplugged (#88#issuecomment-279102884). The script below, which I named
yubissh, helps with that (not tested thoroughly!).Note: you need to create the
~/.local/share/yubisshdirectory first.Both will be supported. Even though there’s overlap when it comes to the YubiKey’s PIV application, the two products have different use cases. The ykman is a tool to manage the YubiKey with its different applications (PIV, FIDO, OTP…etc). yubico-piv-tool is mainly a C library and a PKCS11 module that manages only the PIV application. While yubico-piv-tool as a command line tool can fully be used to manage the YubiKey PIV application just as well as ykman, there are few edge cases where the functionality is available through yubico-piv-tool but not ykman. See https://developers.yubico.com/PIV/Tools.html for some more details
Thanks @brechtm and others. Needless to say this kind of feedback is significantly more useful. There is a longer conversation to be had about documentation and constantly having to play catch-up with a lot of other moving parts like OS upgrades and third-party project changes, but this is not the place for it.
Ultimately the goal is to make the user experience as good as it can be. I hear you (all) when you say that we’re not there, but there’s a lot of things at play. I’ll pass the feedback along and take the conversation internally.
Finally, regarding YubiHSM, that has a different set of challenges, but please open issues in the relevant projects or a support ticket if nothing applies. Feature requests for hardware devices are a separate topic, but bug reports, contributions and documentation change requests and suggestions are always welcome.