#terminal #clipboard #ssh #tmux #osc52

bin+lib sshclip

Copy remote file or stdin content into your local clipboard over SSH via OSC 52 (with tmux support)

1 unstable release

Uses new Rust 2024

0.1.0 Feb 25, 2026

#66 in #clipboard

MIT license

33KB
859 lines

sshclip

sshclip copies file or stdin content from a remote shell into the local workstation clipboard by emitting an OSC 52 escape sequence.

It is designed for SSH workflows and supports tmux passthrough wrapping.

Install

cargo install sshclip

Why this works

OSC 52 is interpreted by the local terminal emulator. Over SSH, bytes printed by the remote process are still rendered locally, so clipboard write requests can be sent without X11 forwarding or a local daemon.

Usage

sshclip [OPTIONS] [FILE|-]
sshclip doctor

Examples:

sshclip ~/.kube/config
kubectl get secret my-secret -o yaml | sshclip
sshclip --selection primary ~/.ssh/id_rsa.pub
sshclip --max-bytes 200000 --truncate big.txt
sshclip doctor

Defaults and safety

  • Output target defaults to /dev/tty (not stdout), so escape sequences do not pollute pipelines.
  • Default size cap is --max-bytes 75000 raw bytes.
  • Exceeding the limit fails with exit code 4 unless --truncate is used.
  • Multiple input paths require --concat.

tmux notes

When inside tmux, sshclip wraps OSC 52 in tmux DCS passthrough framing.

By default, sshclip attempts to:

  1. inspect pane allow-passthrough
  2. enable it temporarily if currently off
  3. restore previous value after emit

Disable mutation with --no-tmux-fix.

If tmux warnings must be fatal, use --strict-tmux.

Exit codes

  • 0: sequence emitted successfully
  • 2: usage / argument error
  • 3: input read error
  • 4: size limit exceeded
  • 5: output device unavailable (for example /dev/tty missing)
  • 6: tmux integration failure in strict mode

Security note

Any program that can print to your terminal can attempt OSC 52 clipboard writes. Treat untrusted commands accordingly.

No runtime deps