Skip to content

Field note

Claude Code over SSH: Tmux and Copy-Paste Fixes

Most copy-paste and line-break problems with Claude Code over SSH are a tmux or terminal setting, not a fault in Claude Code itself.

Most copy-paste and line-break problems with Claude Code over SSH are a tmux or terminal setting, not a fault in Claude Code itself.

Symptoms you are likely to see

Claude Code works on your laptop, but on the remote build box it feels broken. The usual complaints are:

  • Shift+Enter submits the prompt instead of adding a new line.
  • /copy says Copied to clipboard but nothing arrives on the local machine.
  • Click-and-drag selects text inside Claude Code, but Cmd+C or Ctrl+Shift+C copies nothing.
  • A long paste from a ticket or log turns into [Pasted text #1 +120 lines] and someone assumes it was lost.
  • No desktop notification when Claude finishes or asks for permission.
  • The screen flickers or the scroll position jumps while output streams.

Each has a different cause. Fix them in order.

Likely causes, most common first

  1. tmux is swallowing key and escape sequences. By default tmux cannot tell Shift+Enter from plain Enter, and it blocks the passthrough sequences Claude Code uses for notifications and progress. This is the top cause when the same setup works outside tmux.
  2. Clipboard over SSH relies on OSC 52. Claude Code on a remote host cannot run your local clipboard tool. Outside tmux it sends the text to your terminal as an OSC 52 escape sequence and the terminal decides whether to honour it. macOS Terminal.app does not support OSC 52 at all. iTerm2 ignores it until you enable "Applications in terminal may access clipboard" under Settings, General, Selection.
  3. Fullscreen rendering captures the mouse. In fullscreen mode the selection lives inside Claude Code, so tmux copy mode and the terminal's native selection do not see it.
  4. /terminal-setup was run inside tmux. It needs to write to the host terminal's configuration, so run it in the plain terminal, not in a tmux or screen session.
  5. Old tmux. Releases through the 3.6 series do not implement synchronised output, which causes extra flicker under fullscreen rendering.

Step-by-step fix

  1. Confirm the baseline. SSH in, run claude outside tmux, and test Ctrl+J for a new line. Ctrl+J, or \ followed by Enter, works in every terminal with no setup. If that works, the problem is a layer above Claude Code.
  2. Configure tmux. Add these lines to ~/.tmux.conf on the remote host:
set -g allow-passthrough on
set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'

Then apply them to the running server:

tmux source-file ~/.tmux.conf

The first line lets notifications and progress updates reach the outer terminal. The other two let tmux distinguish Shift+Enter from Enter.

  1. Fix the clipboard path. Decide which terminal you use locally and act accordingly. In iTerm2, enable the clipboard access setting above, or run /terminal-setup in a local iTerm2 window, which switches it on for you. In Terminal.app, accept that OSC 52 will not work and use native selection instead.
  2. Use native selection when you need it. Hold the terminal's selection key while dragging: Fn in Terminal.app, Option in iTerm2, Shift in most other terminals including VS Code. Your terminal then owns the selection and Cmd+C works.
  3. If you always want native selection, set CLAUDE_CODE_DISABLE_MOUSE=1 on the remote machine before starting Claude Code. You keep flicker-free rendering and lose in-app mouse handling. Alternatively run /tui default to switch back to the classic renderer, which keeps the conversation in native scrollback so tmux copy mode works as usual.
  4. Use the file fallback for /copy. /copy also writes what it copied to a file and prints the path, so you can scp or cat it when the clipboard does not arrive.
  5. Stop worrying about collapsed pastes. Claude Code collapses anything over 800 characters or three lines into a placeholder but sends the full content when you submit. For whole files or long logs, write them to a file on the remote host and ask Claude to read the path instead.
  6. For mouse wheel scrolling inside tmux in fullscreen mode, add set -g mouse on to ~/.tmux.conf. Fullscreen rendering is not supported in iTerm2's tmux -CC integration mode.

What IT should check

  • The tmux version on shared hosts. Upgrade past the 3.6 series if flicker is a recurring complaint.
  • Whether a standard ~/.tmux.conf is deployed. Three lines in a dotfiles repository saves the same conversation with every new starter.
  • The login flow over SSH. The browser opens locally, so users paste a code into the terminal. If pasting does nothing, use the terminal's alternate paste shortcut such as Shift+Insert, or run claude auth login, which reads the code from standard input. See Claude Code authentication and SSO problems for the wider login checklist.
  • Permission settings, so remote sessions on shared hosts do not run with broader rights than local ones. Our note on safe Claude Code permission prompts covers the defaults worth keeping.

When to escalate to Anthropic

Escalate only when a clean terminal, no tmux and the steps above still fail. Run /doctor first and keep its output. Then use /feedback inside Claude Code, or open an issue on the claude-code GitHub repository, stating the terminal emulator and version, the tmux version, whether the session is over SSH, and the exact message. Keep customer data and credentials out of the report. Account and billing questions go through Get help at claude.ai, not the code repository.

Source basis

Keep reading

Related notes

26 Aug 2026 · 5 min

Claude Code Hooks: Put Checks Before the Merge

A review gate built from Claude Code hooks runs the same cheap checks on every agent action, so the human reviewer only sees diffs that have already passed the boring tests.