[BUG] sshConfigs startDirectory is accepted by the schema but ignored when a session starts
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?
An SSH connection defined in ~/.claude/settings.json with startDirectory connects correctly, but the session opens in the remote user's home directory instead of the directory I specified.
Because session history is keyed on the working directory, the session also starts with an empty history. A machine I had been working on from the CLI opens in the desktop app showing none of my conversations. The transcripts are intact on the host, just stored under the key for the other path, but it reads as data loss.
The field is schema-validated (an invalid type is rejected), so it is accepted and then discarded rather than ignored as unknown.
What Should Happen?
The session opens in the directory given by startDirectory, as documented:
Default working directory on the remote host. Supports tilde expansion (e.g. ~/projects). If not specified, defaults to the remote user home directory.
I did specify it, so the default should not apply.
Error Messages/Logs
Steps to Reproduce
- Add an SSH connection to
~/.claude/settings.json:
``json``
{
"sshConfigs": [
{
"id": "team.project-a",
"name": "Project A",
"sshHost": "project-a",
"startDirectory": "/opt/src/project-a"
}
]
}
- Restart Claude Desktop and open the Code tab.
- Pick "Project A" from the environment dropdown. It connects.
- Ask Claude what the working directory is, or run
pwd. - It reports the remote user's home directory, not
/opt/src/project-a. - On the remote host,
ls ~/.claude/projects/shows a store keyed on the home directory rather than on the configured one, which is why the history looks empty.
Claude Model
_No response_
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.56 (Claude Code); Claude Desktop 1.40609.0
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Why this matters beyond one setting
For anyone managing a fleet of remote development machines, every connection needs a manual folder step before it is usable, per machine and per developer. The published startDirectory is the only mechanism for that, so there is currently no way to hand someone a ready-to-use connection.
Possibly useful
Connections supplied by at least one built-in integration do open at a working directory, so the session model appears to carry one already; it looks like the settings path simply does not pass the value through.
The documented workaround, claude ssh <config> [dir], does not currently run either. Filed separately.
Searched first: #83561 also involves sshConfigs but is a different problem (the SSH environment never appearing in third-party API mode). I found no existing report of startDirectory being ignored.
Desktop app version: 1.40609.0. Also reproduced on 1.37937.3.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗