Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
Ctrl+V images and files into remote Claude Code / Codex over SSH. macOS & Linux remotes; iTerm2, tmux, WezTerm, kitty, Warp.
Jump to setup instructionsFetched from the repository for this visit.
English · 中文
Paste a screenshot — or files copied in Finder — into Claude Code / Codex CLI running on a remote Mac or Linux host over SSH, with a plain Ctrl+V. The same key also pastes local paths into a local shell, and remote paths into a remote one.
| You press Ctrl+V in … | Files on the clipboard | Image on the clipboard |
|---|---|---|
| a local shell (zsh, bash, fish, …) | types the local paths | saves a PNG, types its path |
ssh → a remote AI CLI | uploads, pastes the remote paths | pushes the image to the remote clipboard, then Ctrl+V |
ssh → anything else | uploads, types the remote paths | uploads a PNG, types the remote path |
| anything else (vim, local claude/codex, …) | Ctrl+V untouched | Ctrl+V untouched |
On macOS, Claude Code and Codex read the clipboard image in-process (via NSPasteboard). Over SSH they therefore read the remote machine's clipboard, not the one your screenshot is in. Terminal escape sequences (OSC 52) only carry text. On a macOS remote there is no external command to shim, so the only way in is to put the image on the remote system clipboard before the CLI reads it. On a Linux remote the CLIs run xclip / wl-paste, which can be shimmed — sshpaste does that, so a headless server needs no X/Wayland.
Make the image available on the remote before the CLI reads it:
Ctrl+V ──► [adapter] what is in the foreground? what is on the clipboard?
│ nothing relevant ──► forward Ctrl+V untouched
▼
sshpaste: export PNG ──ssh (1 connection)──► remote macOS: set the system clipboard
remote Linux: drop PNG in ~/.cache/sshpaste
▼
forward Ctrl+V ──► remote CLI reads the clipboard ──► [Image #1]
(Linux: the xclip/wl-paste shim serves the PNG once)
Files work differently, because there is no "file clipboard" on the remote: they are uploaded to ~/.cache/sshpaste/inbox/<timestamp>/ (one SSH connection, tar stream, directories included) and the remote paths are pasted into the terminal, shell-escaped like a drag-and-drop. Claude Code turns pasted image paths into [Image #N] attachments; other files stay as paths it can read with @.
The core, bin/sshpaste, knows nothing about terminals. Adapters only fetch the foreground process and tab title, call sshpaste --action --job NAME [--pid PID] [--title TITLE], and apply its answer: forward (send the real Ctrl+V), swallow, type or paste (then the text). A new terminal takes about 30 lines.
sshpaste --install-remote user@host once. It puts a small xclip/wl-paste shim in ~/.local/bin (which must come first in PATH; it refuses to overwrite a real tool; --uninstall-remote removes it).ControlMaster connection (see Passwordless).Requires macOS locally (bash 3.2+, nothing else). Three steps:
# 1. get it and install the CLI (symlink into ~/.local/bin)
git clone https://github.com/KolorYan/sshpaste.git && cd sshpaste
./install.sh
# 2. Linux remotes only: once per host (macOS remotes need nothing)
sshpaste --install-remote user@linux-host
# 3. enable the adapter for your terminal (pick yours)
| Terminal | One-time setup |
|---|---|
| iTerm2 | ./install.sh --iterm2, enable Settings ▸ General ▸ Magic ▸ Enable Python API, restart iTerm2 |
| tmux (3.2+) | echo "source-file $PWD/adapters/tmux/sshpaste.tmux" >> ~/.tmux.conf |
| WezTerm | two lines in ~/.wezterm.lua (below) |
| kitty | echo "map ctrl+v kitten $PWD/adapters/kitty/sshpaste_kitty.py" >> ~/.config/kitty/kitty.conf |
| Terminal.app, Warp, others | brew install --cask hammerspoon, two lines in ~/.hammerspoon/init.lua (below), grant Accessibility |
Check it works: copy a screenshot (Cmd+Ctrl+Shift+4), ssh to a remote Mac or Linux host, start claude or codex, press Ctrl+V — [Image #1] appears. Without an adapter, sshpaste user@host does the same push from any shell.
| Terminal | Status | How |
|---|---|---|
| iTerm2 | ✅ verified with real keystrokes | Python API, ./install.sh --iterm2 |
| tmux (inside any terminal) | ✅ verified with real keystrokes | source-file |
| WezTerm | ✅ verified with real keystrokes: local shell, non-shell forwarding, ssh upload, remote Claude Code with an image | Lua config |
| kitty | ✅ verified with real keystrokes: local shell, ssh remote shell, remote Claude Code with an image (forwarding checked via remote control) | kitten |
| Terminal.app | ✅ verified with real keystrokes, exact per window/tab | Hammerspoon |
| Warp | ✅ verified with real keystrokes while it has a single session: local shell, and ssh to a remote shell; with two tabs the adapter correctly stays out of the way | Hammerspoon |
| Ghostty | ✅ verified with real keystrokes: local shell, ssh to a remote shell, remote Claude Code with an image; with several tabs the focused one is found by its working directory (AppleScript), and two tabs in the same directory stay ambiguous, so Ctrl+V is forwarded untouched | Hammerspoon |
| Alacritty, VS Code, Cursor | ⚠️ not tried; works only when the app has a single session | Hammerspoon |
./install.sh --iterm2, enable Settings ▸ General ▸ Magic ▸ Enable Python API, restart iTerm2. The host and options are taken from the running ssh process.
(3.2+) In ~/.tmux.conf: source-file /path/to/sshpaste/adapters/tmux/sshpaste.tmux. Works in any terminal emulator, for panes inside a local tmux. It pastes with paste-buffer -p, which uses bracketed paste exactly when the pane's program enabled it, so it does not depend on the title guess (a tmux pane title can be garbage).
In ~/.wezterm.lua:
local sshpaste = dofile(wezterm.home_dir .. "/path/to/sshpaste/adapters/wezterm/sshpaste.lua")
sshpaste.apply(config, { root = wezterm.home_dir .. "/path/to/sshpaste" }) -- debug = true logs each step
A quick --has-clip runs synchronously (one cheap call); everything else runs in the background and answers through wezterm cli send-text, so an upload never freezes the GUI. WezTerm's Lua sandbox has no debug library, hence the explicit root.
In kitty.conf: map ctrl+v kitten /path/to/sshpaste/adapters/kitty/sshpaste_kitty.py. No remote control needed. The kitten starts sshpaste --action as a child process and polls it with kitty's timer — not a thread, because a Python background thread does not get to run in kitty while its main loop is idle. sshpaste is looked up via $SSHPASTE_BIN, PATH, then ~/.local/bin (kitty loads kittens without __file__). SSHPASTE_DEBUG=/some/file writes a trace.
In ~/.hammerspoon/init.lua:
sshpaste = dofile(os.getenv("HOME") .. "/path/to/sshpaste/adapters/hammerspoon/sshpaste.lua")
sshpaste.start()
and give Hammerspoon the Accessibility permission. It only touches Ctrl+V when the clipboard holds files or an image (otherwise it passes through instantly), and pastes text with Cmd+V after a temporary clipboard swap (restored 0.6 s later), so the terminal applies bracketed paste itself; a clipboard manager will see the temporary text. Terminal.app is exact (the selected tab's tty, verified with two windows). For the other apps it uses the app's child processes that own a tty and are in the foreground, and only acts when there is exactly one such session — with several tabs it is ambiguous and Ctrl+V is forwarded untouched rather than risk uploading to the wrong host.
If Ctrl+V does nothing although the Accessibility switch is on, the grant may be stale (for example after Hammerspoon was updated): hs.accessibilityState() returns false. Restart Hammerspoon, or toggle the switch off and on.
Files win over an image (a Finder copy also carries the file's icon as an image, so the image check excludes clipboards with a file URL). Only plain shells get local paths typed in, because Ctrl+V means something in vim, less and REPLs (SSHPASTE_LOCAL_JOBS changes the list). "Remote AI CLI" is guessed from the tab title: Claude Code sets one that starts with a status glyph (✳ ◐ or a braille spinner) — SSHPASTE_AI_TITLE (an ERE, case-insensitive) overrides it. For Claude Code an image goes through the remote clipboard; Codex's title is just the directory name, so it is not recognised, which is harmless: Codex turns the typed remote image path into [Image #1] just the same (both routes verified, Codex 0.158). If an upload fails you get a notification and, when files were involved, nothing is pasted (a forwarded Ctrl+V would paste a stale remote image).
sshpaste user@host # push the clipboard image; any ssh options work: sshpaste -p 2222 -J jump user@host
sshpaste --files [--image] user@host # upload clipboard files (--image: the image as a PNG); prints the remote paths
sshpaste --paths [--image] # no ssh: print the local paths (image saved as a PNG first)
sshpaste --action --job zsh # what would Ctrl+V do here? (forward | swallow | type | paste, then the text)
sshpaste --install-remote user@host # Linux remotes: install the xclip/wl-paste shim (--uninstall-remote removes it)
sshpaste opens its own second ssh connection with BatchMode=yes, so it never prompts and never hangs your terminal. A host that would need a password simply fails fast, Ctrl+V behaves as before, and a notification tells you why. To use password-only hosts, share the login through ~/.ssh/config:
Host *
ControlMaster auto
ControlPath ~/.ssh/cm-%C
ControlPersist 10m
Log in once by hand; later connections, including sshpaste's, reuse it.
| Variable | Meaning | Default |
|---|---|---|
SSHPASTE_MAX_MB | refuse to upload more than this many MB of files | 100 |
SSHPASTE_LOCAL_JOBS | foreground programs that get local paths typed in | zsh bash fish sh dash ksh tcsh nu pwsh |
SSHPASTE_AI_TITLE | ERE matching the tab title of a remote AI CLI | glyphs, claude, codex, gemini, opencode, aider |
SSHPASTE_CLIPS | where clipboard images are saved locally (pruned after 7 days) | ~/.cache/sshpaste/clips |
SSHPASTE_BIN | path of sshpaste for adapters | adapter-specific lookup |
SSHPASTE_DEBUG | 1 traces the core to stderr; a file path is used by the kitty kitten | off |
0 pasted · 10 no image in the local clipboard · 11 no ssh destination · 12 remote OS unsupported · 13 ssh failed · 14 local export failed · 15 remote clipboard write failed · 16 Linux remote has no shim · 17 install refused · 18 no files in the clipboard · 19 files over SSHPASTE_MAX_MB · 20 unsafe or duplicate file name.
xclip/wl-paste; it is not placed in a real X/Wayland clipboard. On macOS it overwrites the remote clipboard.~/.cache/sshpaste/inbox/; directories older than 7 days are pruned on the next upload. Two files with the same name in one copy, or names with control characters, are refused. Some clipboard managers collapse a synthetic multi-file clipboard to one item (seen with Maccy on a hand-built clipboard; a real Finder copy was fine). With several files at once Claude Code attaches the images among them; Codex attaches only when the pasted text is a single image path, the rest stay readable paths.ssh: No route to host), so neither ssh nor sshpaste works in it — allow it under System Settings ▸ Privacy & Security ▸ Local Network.ssh. ssh inside a remote tmux is fine; a local tmux needs the tmux adapter; mosh is not supported.ps output, so arguments containing spaces (e.g. -o ProxyCommand=...) are not reconstructed exactly — put them in ~/.ssh/config. Forwards (-L/-R/-D/-W) and RemoteCommand of the original session are deliberately not replayed.The image and files travel only over your existing SSH trust (same host, same keys). Nothing is sent unless you press Ctrl+V with an image or files on the clipboard while an ssh job is in the foreground. Files you copy are uploaded to the remote host in full, so check what is on the clipboard before pressing Ctrl+V in a session to a machine you do not fully trust. On macOS the remote copy lives in a mktemp file removed right after it is placed on the clipboard; on Linux it lives in ~/.cache/sshpaste/clip.png until read (valid for at most 2 minutes). File names with control characters are refused, because an escape sequence or newline would otherwise be pasted or typed into your terminal.
tests/run.sh # offline: ssh / osascript / ps / uname are stubbed
Apache-2.0 — see LICENSE.
GitHub checked 208h ago - refresh overdue. Recently viewed repositories target hourly refresh.
Find a documented setup for your client. No sign-in, installation, or tool execution.
If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.