[BUG] Claude Code SSH Authentication

Resolved 💬 3 comments Opened Sep 9, 2025 by gohabsgo2142 Closed Sep 13, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Problem Summary
Claude Code authentication fails when running over SSH connections, showing "Invalid API Key" error even when attempting account login (not API key authentication). This issue persists across all installation methods (npm, native installer, homebrew cask).
Environment Details

OS: macOS
Claude Code Version: 1.0.109
Installation Methods Tested: npm global, native installer, homebrew cask
Connection: SSH from local Mac to remote Mac
Shell: zsh

Troubleshooting Attempted

✅ Tried multiple installation methods (npm, native, homebrew cask)
✅ Cleared configuration files (~/.claude, ~/.claude.json)
✅ Verified local authentication works (same machine, not over SSH)
✅ Checked environment variables for API key conflicts
✅ Removed conflicting installations

Impact

Cannot use Claude Code in remote development environments
Forces local-only development workflow
Impacts productivity for developers using SSH-based workflows

Workaround
None found. Issue persists regardless of:

Installation method
Configuration cleanup
SSH forwarding options

Additional Notes
This appears to be a fundamental issue with Claude Code's OAuth authentication flow when running in SSH environments, where browser-based authentication may not work as expected.
The error message "Invalid API Key" is misleading since this occurs during account login attempts, not API key authentication.

Request: Please investigate SSH compatibility for Claude Code authentication or provide alternative authentication methods for SSH environments.

What Should Happen?

Expected Behavior

claude auth login should open browser authentication flow
User should be able to complete OAuth flow
Authentication should persist for future sessions

Actual Behavior

Gets "Invalid API Key" error message
Authentication fails completely
Cannot use Claude Code over SSH

Error Messages/Logs

Steps to Reproduce

Steps to Reproduce

SSH into remote macOS machine: ssh user@remote-mac
Run Claude Code: claude
Attempt authentication: claude auth login
Observe "Invalid API Key" error despite using account login (not API key)

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Not remember

Claude Code Version

1.0.109 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

I use Termius but same thing in the normal Terminal

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗