Fix: User interaction is not allowed Error When Codesigning macOS App via SSH/Jenkins

Fix: User interaction is not allowed Error When Codesigning macOS App via SSH/Jenkins

Written by

in

Quick answer: The error occurs because the SSH session lacks a GUI login session, so the keychain stays locked. Fix it by adding the login keychain to the search list with security list-keychains -s (without -d system), unlocking it, and setting the signing key’s Access Control to “Allow all applications to access this item” in Keychain Access.

Why this happens

When a macOS build runs over SSH (Jenkins, GitHub Actions self-hosted, etc.), the session is non-interactive. The security tool cannot unlock a keychain unless it’s in the user’s keychain search list and the calling process has a valid login session. The -d system flag on list-keychains targets the system domain, which doesn’t affect the per-user search list used by codesign. Additionally, the private key’s Access Control defaults to “Confirm before allowing access”, which prompts for UI interaction—impossible in a headless SSH shell.

How to fix it

1. Add the keychain to the user search list and unlock it

Replace any list-keychains -d system calls with the user-domain version. Run these steps before codesign:

# KEYCHAIN is the path to your dedicated keychain (e.g. $HOME/.secret/App.keychain)
# KEYCHAIN_PASSWORD is the password for that keychain

# Add the keychain to the *user* search list (no -d system)
security list-keychains -s "$KEYCHAIN" "$HOME/Library/Keychains/login.keychain"

# Verify it's present
security list-keychains

# Unlock the keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN"

# Now sign
codesign --sign "$SIGNER_IDENTITY" --force --signature-size 9600 \
         --timestamp --verbose "$APP"

Key points:
– Omit -d system; the user search list is what codesign consults.
– Keep login.keychain in the list so system identities remain available.
– Use --timestamp so the signature remains valid after the certificate expires.

2. Allow all applications to access the private key

Even with an unlocked keychain, the key’s ACL may still demand user confirmation.

  1. Log in to the build machine via GUI as the build user.
  2. Open Keychain Access.
  3. Locate the signing certificate’s private key (disclosure triangle next to the certificate).
  4. Right-click the private key → Get Info → Access Control tab.
  5. Select “Allow all applications to access this item”.
  6. Click Save Changes and enter the keychain password.

This stores an ACL entry that lets codesign (or any tool) use the key without a UI prompt.

3. Alternative: Create a dedicated login-session launch agent (advanced)

If you cannot log in via GUI, you can simulate a user session with launchctl bootstrap gui/$(id -u) /Library/LaunchAgents/your.agent.plist and set SessionCreate = true. This is fragile and rarely needed once the two steps above are applied.

How to prevent it

  • Always use security list-keychains -s (user domain) in CI scripts.
  • Store the signing key in a dedicated keychain and set its ACL to “Allow all applications”.
  • Run a one-time GUI login on each new build agent to configure the ACL.
  • Avoid -d system with list-keychains; it modifies the system domain, not the user domain.
  • Keep login.keychain in the search list so Apple-issued identities remain resolvable.

FAQ

Why does security unlock-keychain appear to do nothing in Keychain Access?

The GUI shows the keychain lock state, but unlock-keychain only unlocks it for the current process tree. If the keychain isn’t in the search list, codesign never sees it as unlocked.

Can I avoid the GUI step for the ACL change?

Yes. Export the private key with security export and re-import with security import -A (allow all), or use SecKeychainItemSetAccessWithCallback via a small Swift tool. The GUI method is simpler and only needed once per machine.

Does this apply to Xcode Cloud or GitHub Actions macOS runners?

Hosted runners already run in a proper login session with the keychain unlocked and ACLs configured. The error typically appears only on self-hosted SSH agents.


Tested on macOS 13–15 with Xcode 15–16. The security command syntax has been stable since OS X 10.7.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 3.0; this article is shared under the same license.