[BUG] [SOLVE!] Missing API key when SSH'ing into macOS

Resolved 💬 24 comments Opened Aug 10, 2025 by kennedybaird Closed Jan 9, 2026

This is my current fix for the bug mentioned across multiple issues: #5244 #5369 #5242 #5235 #5167 #5166 #5118

  1. Run security unlock-keychain ~/Library/Keychains/login.keychain-db
  2. Run claude, complete login flow
  3. You will still see Missing API key error
  4. Type exit
  5. Run claude again and message will be gone.

The above works for me on latest native install:

Diagnostics
 └ Currently running: native (1.0.72)
 └ Path: /Users/kennedybaird/.local/bin/claude
 └ Invoked: /$bunfs/root/claude
 └ Config install method: native
 └ Auto-updates enabled: true

View original on GitHub ↗

24 Comments

github-actions[bot] · 11 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5244
  2. https://github.com/anthropics/claude-code/issues/5225
  3. https://github.com/anthropics/claude-code/issues/5369

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

icaca · 11 months ago

well done

duanehutchins · 11 months ago

Works for me! Thank you @kennedybaird
Hopefully Anthropic fixes this bug, soon, or at least communicates an update or maybe even an acknowledgement of the issue.

decky-grande · 11 months ago

Great job! it works!
Is this solution permanent, or should it be rerun after reboot? If so, is there any way to make it permanent? like putting in a startup script or something

casekhor · 11 months ago

Thanks, worked a treat. Used this in conjunction with claude setup-token.

EDIT: as @sahsu points out below, this may trigger API usage.

sahsu · 11 months ago
Thanks, worked a treat. Used this in conjunction with claude setup-token.

this will generate API mode hope you check already.

RIT-MW · 11 months ago

I needed to run it twice
security unlock-keychain ~/Library/Keychains/login.keychain-db

then it worked (so whole process twice)

iambaseddev · 11 months ago

Thank you. I wasted 2 hours trying to debug it. Your solution worked.

DravenTJU · 11 months ago

Thank you very much, the issue has been resolved after following your advice.

NightMachinery · 11 months ago

This did not work for me. I tried running it twice, too. The command also doesn't seem to produce any errors even I enter a random password for the keychain.

dansteingart · 11 months ago

Furthering the ssh theory, this seems to be an issue of the copied/pasted token

Pure SSH

If I

  1. ssh in,
  2. Start Claude code
  3. Get the URL
  4. Paste the URL locally and get the token
  5. Paste the token into the SSH terminal

The missing API bug persists. _but_

SSH/Screen Sharing combo

If I

  1. ssh in,
  2. Start Claude code
  3. VNC into the instance and use the remote browser to complete the login

everything works

BonjourYY · 11 months ago

Thank you, your method successfully solved my problem. However, I'm very disappointed with Claude Code; I found many issues related to it, but they haven't been resolved. This is irresponsible!

PastaPastaPasta · 10 months ago

Hey guys, this is an important regression. Can someone please at least acknowledge it? This makes life much more annoying for me if I need to run this command each time I run claude.

GBmonmon · 10 months ago

Does not work... Claude clearly has bug when it comes to remote-ssh. Probably just a security choice, because it totally prevent people from hacking into your terminal with remote-ssh and use the AI resources

adamavenir · 10 months ago

Confirmed I'm still getting this issue when attempting to use claude in an ssh'd session

xiaohei-info · 10 months ago

This works on the local terminal but still doesn't work on remote ssh or tmux/screen sessions.
Any help idea? THX!

McPolemic · 10 months ago

This worked for me over SSH, though I had to run unlock-keychain twice before it worked.

Diveafall · 9 months ago

I have this issue as well and none of the solutions here worked.

buritica · 9 months ago

running security unlock-keychain worked for me (and also logging in locally through vnc, but I used /logout first
)

mimkorn · 9 months ago

Is there some trick so that I don't have to do the unlock-keychain thing everytime i want to use claude over phone?

For now I added this to my fish terminal:

if set -q SSH_CONNECTION; and not set -q KEYCHAIN_UNLOCKED security unlock-keychain ~/Library/Keychains/login.keychain-db set -gx KEYCHAIN_UNLOCKED true end

so that I'm prompted for password first thing I open ssh terminal. Minor improvement.

pedrofausto · 8 months ago
This is my current fix for the bug mentioned across multiple issues: #5244 #5369 #5242 #5235 #5167 #5166 #5118 1. Run security unlock-keychain ~/Library/Keychains/login.keychain-db 2. Run claude, complete login flow 3. You will still see Missing API key error 4. Type exit 5. Run claude again and message will be gone. The above works for me on latest native install: `` Diagnostics └ Currently running: native (1.0.72) └ Path: /Users/kennedybaird/.local/bin/claude └ Invoked: /$bunfs/root/claude └ Config install method: native └ Auto-updates enabled: true ``

It really worked. If you're running within a IDE (like VSCode) you have to unlock from the opened terminal within the IDE. Is obvious but some people can miss that (like I did in the first try).

github-actions[bot] · 7 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] · 6 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.