-
Notifications
You must be signed in to change notification settings - Fork 38
Sonoma 14.6 breaks ssh-askpass #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems the service can't start:
But it's still not running:
When trying to start it:
I tried deleting the |
@dataviruset You can directly set SSH_ASKPASS and SUDO_ASKPASS to test it without the services. It is due to the system I think, not the services
|
Using my original
Interestingly the |
I added keys to the ssh-agent using keepassxreboot/keepassxc#9955 (comment) macOS 14.6 upgrade break ssh-agent |
If your organisation depends on this working and has a support agreement with Apple, please point them at this bug. 😄 I dug in to this a bit today, it looks like Sonoma 14.6 has changed the environment variable inheritance rules for system-provided user daemons ( This means that when macOS starts The work-around @zeyugao proposed side-steps all of this by not using macOS' On a system with Sonoma 14.5 with
On a system with Sonoma 14.6 without
With Sonoma 14.6 with
Other macOS system daemons (eg: User-installed software in The fact that I suspect that this was part of some other security / platform hardening change, but I'm unable to find any specific release notes about this. It's something that Apple will need to fix. |
@micolous Have you succeeded in setting I manually set the |
No. What matters is the environment that The error we're seeing is because
The work-around I've got for now is to disable confirmation, but I've set up my SSH keys using It just means now I don't get any prompt on screen, just a flashing light on the side of my computer. If you're using |
I worked around it by running a user-land instance of Some GUI apps might not pick that up, but so far without issues. Other than it being annoying to setup. For anyone interested here are some resources that helped me:
Given the fact Apple likely broke this for good I think that will be the way forward. |
Yeah, your setup and 1Password's replace the default Apple-provided SSH agent setup (partially or entirely). There are usability edge cases to that, as you've already noted. If you go further (as 1Password do, and has been suggested elsewhere) and replace I acknowledge that there are tradeoffs, like that those hardening features can also prevent you from using some more "obscure" functionality (like FIDO2 resident keys and PIV with ECDSA keys). For what it's worth, there are large corporates and government agencies with macOS workstations and a custom At this point, I'm quietly optimistic that it won't remain broken forever... it just needs to get in front of the right set of eyes. 😄 |
I think the issue has been (at lease partially) misdiagnosed by @micolous; (FWIW I use a different askpass program but I think the issue is similar) As an experiment, I tried unsetting the
So I add a tiny script to the above location: #!/bin/sh
echo "$@" > ~/askpass
date >> ~/askpass
env >> ~/askpass I notice that when keys are not loaded, I get output as follows:
In particular, the
i.e. the script runs in the same context as the ssh command, likely invoked directly by Whereas if keys are loaded I get similar to the following: $ cat ~/askpass
Allow use of key user@host?
Key fingerprint SHA256:<redacted>.
SHELL=/bin/zsh
SSH_ASKPASS_PROMPT=confirm
TMPDIR=/var/folders/vx/wq1n25gs5t54v4sp3_6yj3c00000gn/T/
MallocSpaceEfficient=1
USER=user
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.LVjkwSsCS6/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PWD=/
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/user
LOGNAME=user
DISPLAY=/private/tmp/com.apple.launchd.NVQ3vVyfbz/org.xquartz:0
_=/usr/bin/env which is a fairly vanilla environment, likely invoked by The conclusion is that rather than not recognizing |
update: I can confirm that
where programs are at the respective locations above opens the confirmation dialog and proceeds to successfully authenticate. Presumably pointing EDIT: |
I tried your work-around on Sonoma 14.5 and 14.6 with XQuartz installed (so I removed the brew services stop ssh-askpass
launchctl unsetenv SSH_ASKPASS
launchctl unsetenv SUDO_ASKPASS
unset SSH_ASKPASS
unset SUDO_ASKPASS
killall ssh-agent I then added the keys again with confirmation enabled: # For SSH key in the Keychain:
ssh-add -cs /usr/lib/ssh-keychain.dylib
# If you were using a private key stored on disk, you would do:
ssh-add -c I tested putting both your tiny script and this repository's version of Even adding a symlink to a Homebrew-installed version of Looking at the source of Apple's version of SSH, it will try to use This would suggest that the only trigger for the issue is that environment variables from While I don't doubt that (This post was edited multiple times to clarify things.) |
A step-by-step, minimum-viable workaround for Sonoma 14.6 and later with macOS' default, out-of-the-box
Then you can load your keys into your SSH agent as normal ( This should also work on Sonoma 14.5 and earlier, if you want to prepare a system before upgrading to 14.6. A work-around without XQuartz would be to have Edited (2024-08-06): Fix typo: replace Edited (2025-02-18): Added that you may need to log out and log in again after installing XQuartz for the |
An alternative workaround is to clone and shadow the original system launch-agent, which cannot be disabled or modified (due to SIP), and does not inherit global environment. Make a copy: cp /System/Library/LaunchAgents/com.openssh.ssh-agent.plist ~/Library/LaunchAgents/com.openssh.ssh-agent-my.plist Change:
Load the launch-agent launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.openssh.ssh-agent-my.plist Even if it's the same executable, it does inherit the global environment as it is not a system launch-agent. So it gets the Restart your terminal app to acquire the fresh global env. Now the To make it work in your terminal, you can override the original env variable in your shell config: export SSH_AUTH_SOCK=$SSH_AUTH_SOCK_MY To make it work with all apps, we have to override the socket-file itself: ln -sf $SSH_AUTH_SOCK_MY $SSH_AUTH_SOCK (Idea source: maxgoedjen/secretive Finally, it's working just as before the OS upgrade. |
@micolous - However, there's no mention of |
@sprig Yes, that was a typo, I've now fixed that, thanks. 😄
Note: I've set On a system with Sonoma 14.5 on
On a system on Sonoma 14.6 on
Out of the box, this is a broken symlink. This is from a machine with Sonoma 14.6 on
I also jumped into macOS recovery on a machine running Sonoma 14.6 on There's no By default, the user data partition isn't mounted, and the (sealed) OS partition is mounted as read-only at All of the macOS systems I used have always had system integrity protection enabled. I'll leave reproducing this on a fresh install of macOS as an exercise for the reader. 😄
@D54 You'll have run this every time you log in. GUI app compatibility is one of the draw-backs of not using Apple's provided By comparison, the work-around I proposed works with everything that Apple's default |
Wow! What an active and amazing community we have! ❤️ I'll try to answer the unanswered questions and correct, as best as I can, a few things. |
I'm guessing this is because of #53 We don't actually have a process running we just use the service to set the
I've never seen this before and the output is not something we do. Uninstall and reinstall to get the correct version. |
This is basically it. Apple released a new version and it had an unintended bug in it by removing environment variables from system agents that is set by Why do we classify this as a bug?
AFAICT |
@micolous proposed work-around works. Homebrew doesn't want us to write to |
If I understand the logic correctly if This is also why you don't get a password prompt with |
@micolous and @D54 got me thinking of a very ugly idea... 😆 We could, and I just tried it - it works, in our launchd plist:
It's NOT pretty but it works. But since there are workarounds we'll wait a bit for Apple to fix it. We are not the only ones using But if you have a support contract please remember to contact Apple about it! |
Hi are you folks also seeing ssh-agent being unable to respond to connect requests after the update until ssh-add is called? |
|
14.6.1 is released, is it fixed or it is intended by apple? |
@zeyugao The issue is not fixed in Sonoma 14.6.1. If you want to test if a version of macOS is affected (without installing # Set SSH_ASKPASS to reject all requests, but only if it is unset.
[ -z "$(launchctl getenv SSH_ASKPASS)" ] && launchctl setenv SSH_ASKPASS /bin/false
# Check for SSH_ASKPASS from ssh-agent's environment
launchctl print gui/$UID/com.openssh.ssh-agent | grep SSH_ASKPASS If the second command returns nothing, then that version of macOS is affected by the issue. If the second command returns To explicitly unset launchctl unsetenv SSH_ASKPASS |
I don't think On a Sonoma 14.5
On a Sonoma 14.6.0 and 14.6.1
Interestingly, the security release notes for Sonoma 14.6 says:
There are similar patches for There aren't any publicly-available details around what that bug actually is, which is normal for an issue that's either privately disclosed or discovered internally at Apple. My outsider, armchair theory is:
There have been narrower environment variable restrictions in the past: the previous (open source) version of I still feel that this issue may be an unintended side-effect: Apple's default |
here is the workaround I am using: this stops any other ssh-agent, then uses its own socket env var to start the agent with custom config, then symlinks the original ssh socket to the custom one |
@MichaelRoosz Won't launchd use socket activation and start a new ssh-agent and inherit |
@simmel due to the symlink, socket activation will start the custom ssh-agent |
The workaround is actually pretty similar to this workaround posted earlier, but automates the socket symlinking hack at the end. All of the
In any case, if a future macOS version starts protecting Launching |
@micolous the setenv (at least SSH_SK_PROVIDER) are needed to make the other ssh tools pickup the FIDO2 provider lib. they are there for a reason. SSH_ASKPASS was needed to make ssh work when used by ansible, if I remember correctly, but it surely does not hurt to set it. to be honest, it is a shame that Apple does not support setting these configs in an easy way without needing to use those workarounds. I really hope they properly implement a way to configure the ssh-agent before they mess it up even more. |
From the comments and suggestions here, I tried to use the workaround masking the system I compiled my solution into a gist (https://gist.github.com/lepus2589/5235d78172e529b2d076d2c0e9670b27). Feel free to test it and to give feedback! |
I made a self-contained installer / uninstaller here. The script is aware of the 1Password location – because that's what I use – but if there's a similarly pre-defined socket path for AskPass, just add it here before running the script.
|
@lepus2589 @schiffy91 Sorry maybe this is basic but I've been trying to figure this out for 3 days now. What would I have to add to known sockets here to make this script work? I'm not doing anything fancy I just have OpenSSH installed from homebrew and want to use my yubikey with Fido2 for ssh and have agent forwarding working. Any help is appreciated and thanks for all the work that everyone put into figuring out the issue. |
You could also add it to the KNOWN_SOCKETS array, as you have pointed out, which is only aware of 1Password and GPG, but I can always update the script with more paths. |
@schiffy91 I took some time to read over your script and I believe you are trying to use a different agent than the simple ssh-agent. I just want to use the user started default ssh agent which means I shouldn't have to pass in anything as far as I understood as the solution by @lepus2589 already takes care of everything and you just add an extra step of replacing the agent to one the one you use instead of the one that gets started in user-space by https://gist.github.com/lepus2589/5235d78172e529b2d076d2c0e9670b27#file-com-openssh-ssh-agent-overlay-sh. Would be great if the script worked without having to specify alternate agent since it will then just use the above user-space ssh-agent. I would be happy to contribute but I don't know what I'm doing and spent a whole day just to decipher what the script was doing. Please correct me if I am wrong. |
I've followed the instructions by @lepus2589 and checked that everything is working as he described and when I invoke ssh-add I do get a dialog but never when I try to ssh to a machine. It never invokes ssh-askpass and I cannot figure out why for some reason. I just get agent refused operation. Someone please help as I will go insane trying to debug this with my limited skills. |
@Boracem1 My previous comment describes setting up with stock The stock Apple However, some security keys (like Yubikey) support PIV in addition to U2F and FIDO2 – check with your security key vendor if they support it, or how to enable it. The Apple There's instructions for setting up PIV for SSH here, but that was written before Sonoma 14.6: so you'll need to use the The important things that need to happen are:
Keep in mind that any environment variable that you set up in your shell, or your For posterity: anything that needs to replace |
@lepus2589 From your post:
Setting the Trying to race |
@micolous Why is it that ssh-add does show a prompt for pin? Also what is your recommended solution for using fido since I have the Yubikey bio fido edition. |
@Boracem1 Because
The short answer is that I wouldn't use FIDO2 for SSH authentication. It's an (admittedly novel) hack to get a security key to sign something that is vaguely SSH shaped, but requires server compatibility to make it work (some large cloud providers don't support), and throws out many WebAuthn security features in the process (though some of these don't have equivalents in SSH). Longer term, I expect macOS to start locking down use of U2F/FIDO2 devices in a similar way to what Microsoft has already done on Windows 10 and 11, where all access to hardware authenticators must go through their platform WebAuthn API. macOS has a similar "Passkeys API for Web Browsers", but getting access to that is significantly more restricted than it is on Windows. This will break There may be a way to have your device's secure element/enclave (aka: "Touch ID") generate a certificate for use with SSH, and expose it via What limits you is that But as I previously mentioned, I suspect that this is to fix a security bug or weakness. The exact nature of the issue was not disclosed publicly, and that'll limit what Apple can / will "reasonably" do. |
if you need an easy solution on macOS with homebrew:
this takes care of everything (installs the fido2 ssh module and configures ssh-agent) |
From #54 (comment)
I tried to do this with MacPorts, which is also officially supported by the XQuartz project (https://www.xquartz.org/releases/index.html#macports): $ sudo port -v install xorg-server Both the Any ideas? Is this a bug in the MacPorts package? BTW, @micolous, why would the injection into the system agent work for the |
Re @lepus2589:
Maybe. MacPorts I've installed XQuartz on a fresh Sequoua 15.3.1 install with Homebrew's So my suggestion would be to just install the upstream package from the XQuartz website. You'll end up with two XQuartz installs if some other MacPorts package depends on it, but at least one of them should work. 🙃
Because it uses The value of an environment variable set by Because it's not possible to have two Apple might decide prevent anything from replacing a system-provided |
@micolous Thanks again for taking the time for this detailed explanation! I tried deactivating the MacPorts package and installing the XQuartz.pkg package, and it worked as advertised. The After uninstalling the pkg package again and reactivating the MacPorts package, magically, the So, for anybody else, who has this problem with the MacPorts Edit: It turns out, I also had to disable the ssh-askpass plist. The stopping of the system ssh service |
Just after update to Sonoma 14.6 today I get:
Same for my co-worker, it definitely worked ok on 14.5 just before this update (hours ago).
The text was updated successfully, but these errors were encountered: