[BUG] SSH fails with "No user exists for uid 501" in background/agent-view mode, but works fine in standalone CLI

Open 💬 0 comments Opened Jul 15, 2026 by thinkycx

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?

## Summary

SSH (and any command calling getpwuid()) fails in the Bash tool with:

No user exists for uid 501

This ONLY happens in agent view / background job mode. Running the same SSH command in a standalone claude CLI session works fine.

## Reproduction

  1. macOS (Darwin 23.6.0)
  2. Launch Claude Code in agent view (background job / subagent)
  3. Run any SSH command via the Bash tool:

ssh user@host -i ~/.ssh/key "echo hello"

  1. Result: No user exists for uid 501 (exit code 255)

Works fine: The exact same command succeeds in a standalone claude session (not agent view).

## Root cause

The agent-view / background-job process appears to run in a more restricted environment where Directory Services is inaccessible. getpwuid(501) fails at the C library level, and SSH exits immediately on init.

Verified:
```python
import os, pwd
pwd.getpwuid(os.getuid()) # KeyError in agent view, succeeds in standalone

dangerouslyDisableSandbox: true does not help — the restriction is at the process environment level, not the sandbox layer.

Expected behavior

Agent view / background jobs should have the same system call access as standalone CLI sessions, or provide a way to opt out of the additional restrictions.

Environment

  • macOS 14.x (Darwin 23.6.0)
  • Claude Code (latest)
  • Agent view / background job mode

What Should Happen?

need to allow it ssh <host> in agent view mode

Error Messages/Logs

Steps to Reproduce

macOS (Darwin 23.6.0)

  1. Launch Claude Code in agent view (background job / subagent)
  2. Run any SSH command via the Bash tool:

ssh user@host -i ~/.ssh/key "echo hello"
Result: No user exists for uid 501 (exit code 255)

  1. Works fine: The exact same command succeeds in a standalone claude session (not agent view).

Claude Model

_No response_

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.144

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗