[BUG] When connected via the integrated SSH terminal in Claude Desktop

Open 💬 0 comments Opened Jul 4, 2026 by Attesh

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?

Description

When connected via the integrated SSH terminal in Claude Desktop, the interactive terminal correctly starts in the project directory because .bashrc on the remote host contains a cd:

cd /var/www/apexnova-tools

Confirmed in the terminal itself:

root@srv1696531:/var/www/apexnova-tools# pwd
/var/www/apexnova-tools

However, when Claude executes commands internally (Run command / Bash tool) over the same SSH connection, it always starts from /root instead of the terminal's current working directory:

pwd
/root

Root cause (suspected)

Bash only sources .bashrc for interactive shells. The integrated terminal is an interactive login session, so the cd in .bashrc runs. Claude's internal command runner appears to open a non-interactive shell (or exec a command directly) over the SSH connection, which does not source .bashrc, so it falls back to the SSH user's home directory (/root) instead of the project directory.

Impact

Because Claude's internal commands run from the wrong directory, it:

  • searches for files in /root instead of the project
  • creates files in /root instead of the project
  • fails to find the project entirely
  • effectively ignores the terminal's actual working directory

Expected behavior

One of the following:

  1. Claude's internal command execution uses the same working directory as the active terminal session (or the directory the SSH session was opened into).
  2. The login shell's working directory (post .bashrc/.profile) is respected for internal command execution too.
  3. Claude Desktop allows configuring a default remote working directory per SSH connection (e.g. /var/www/apexnova-tools).
  4. The working directory is preserved across command executions within a session instead of resetting to /root each time.

Environment

  • Claude Desktop
  • Remote SSH connection
  • Ubuntu Server
  • Bash
  • Interactive terminal starts correctly in /var/www/apexnova-tools
  • Only Claude's internal command execution incorrectly uses /root

What Should Happen?

Description

When connected via the integrated SSH terminal in Claude Desktop, the interactive terminal correctly starts in the project directory because .bashrc on the remote host contains a cd:

cd /var/www/apexnova-tools

Confirmed in the terminal itself:

root@srv1696531:/var/www/apexnova-tools# pwd
/var/www/apexnova-tools

However, when Claude executes commands internally (Run command / Bash tool) over the same SSH connection, it always starts from /root instead of the terminal's current working directory:

pwd
/root

Root cause (suspected)

Bash only sources .bashrc for interactive shells. The integrated terminal is an interactive login session, so the cd in .bashrc runs. Claude's internal command runner appears to open a non-interactive shell (or exec a command directly) over the SSH connection, which does not source .bashrc, so it falls back to the SSH user's home directory (/root) instead of the project directory.

Impact

Because Claude's internal commands run from the wrong directory, it:

  • searches for files in /root instead of the project
  • creates files in /root instead of the project
  • fails to find the project entirely
  • effectively ignores the terminal's actual working directory

Expected behavior

One of the following:

  1. Claude's internal command execution uses the same working directory as the active terminal session (or the directory the SSH session was opened into).
  2. The login shell's working directory (post .bashrc/.profile) is respected for internal command execution too.
  3. Claude Desktop allows configuring a default remote working directory per SSH connection (e.g. /var/www/apexnova-tools).
  4. The working directory is preserved across command executions within a session instead of resetting to /root each time.

Environment

  • Claude Desktop
  • Remote SSH connection
  • Ubuntu Server
  • Bash
  • Interactive terminal starts correctly in /var/www/apexnova-tools
  • Only Claude's internal command execution incorrectly uses /root

Error Messages/Logs

### Description

When connected via the integrated SSH terminal in Claude Desktop, the interactive terminal correctly starts in the project directory because `.bashrc` on the remote host contains a `cd`:


cd /var/www/apexnova-tools


Confirmed in the terminal itself:


root@srv1696531:/var/www/apexnova-tools# pwd
/var/www/apexnova-tools


However, when Claude executes commands internally (Run command / Bash tool) over the same SSH connection, it always starts from `/root` instead of the terminal's current working directory:


pwd
/root


### Root cause (suspected)

Bash only sources `.bashrc` for *interactive* shells. The integrated terminal is an interactive login session, so the `cd` in `.bashrc` runs. Claude's internal command runner appears to open a non-interactive shell (or exec a command directly) over the SSH connection, which does not source `.bashrc`, so it falls back to the SSH user's home directory (`/root`) instead of the project directory.

### Impact

Because Claude's internal commands run from the wrong directory, it:
- searches for files in `/root` instead of the project
- creates files in `/root` instead of the project
- fails to find the project entirely
- effectively ignores the terminal's actual working directory

### Expected behavior

One of the following:
1. Claude's internal command execution uses the same working directory as the active terminal session (or the directory the SSH session was opened into).
2. The login shell's working directory (post `.bashrc`/`.profile`) is respected for internal command execution too.
3. Claude Desktop allows configuring a default remote working directory per SSH connection (e.g. `/var/www/apexnova-tools`).
4. The working directory is preserved across command executions within a session instead of resetting to `/root` each time.

### Environment

- Claude Desktop
- Remote SSH connection
- Ubuntu Server
- Bash
- Interactive terminal starts correctly in `/var/www/apexnova-tools`
- Only Claude's internal command execution incorrectly uses `/root`

Steps to Reproduce

Description

When connected via the integrated SSH terminal in Claude Desktop, the interactive terminal correctly starts in the project directory because .bashrc on the remote host contains a cd:

cd /var/www/apexnova-tools

Confirmed in the terminal itself:

root@srv1696531:/var/www/apexnova-tools# pwd
/var/www/apexnova-tools

However, when Claude executes commands internally (Run command / Bash tool) over the same SSH connection, it always starts from /root instead of the terminal's current working directory:

pwd
/root

Root cause (suspected)

Bash only sources .bashrc for interactive shells. The integrated terminal is an interactive login session, so the cd in .bashrc runs. Claude's internal command runner appears to open a non-interactive shell (or exec a command directly) over the SSH connection, which does not source .bashrc, so it falls back to the SSH user's home directory (/root) instead of the project directory.

Impact

Because Claude's internal commands run from the wrong directory, it:

  • searches for files in /root instead of the project
  • creates files in /root instead of the project
  • fails to find the project entirely
  • effectively ignores the terminal's actual working directory

Expected behavior

One of the following:

  1. Claude's internal command execution uses the same working directory as the active terminal session (or the directory the SSH session was opened into).
  2. The login shell's working directory (post .bashrc/.profile) is respected for internal command execution too.
  3. Claude Desktop allows configuring a default remote working directory per SSH connection (e.g. /var/www/apexnova-tools).
  4. The working directory is preserved across command executions within a session instead of resetting to /root each time.

Environment

  • Claude Desktop
  • Remote SSH connection
  • Ubuntu Server
  • Bash
  • Interactive terminal starts correctly in /var/www/apexnova-tools
  • Only Claude's internal command execution incorrectly uses /root

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

destop

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗