All posts

1 min read

Pasting a Mac screenshot into Claude Code over SSH

A clipboard helper for a remote Claude Code session, and why I stopped needing it after moving Claude back to my Mac.

I used to run Claude Code on a dev server over SSH. When I copied a screenshot on my Mac and tried to paste it into the remote session, Claude could not see the image. The terminal carried my keystrokes to the server, but the image was still on my Mac's clipboard.

I built cpssh to move the screenshot to the server and give the terminal a path Claude could read.

Moving the image

A background daemon watches the Mac clipboard for images. When it finds one, it sends the PNG over SSH to a file under ~/.cpssh on the server. It then puts the image and a text reference to that remote file on the clipboard. A terminal paste gets the path; an image app can still get the PNG.

Clipboard problems

The clipboard handling took a few attempts. One version stopped writing back to the clipboard because it interfered with pasting into Slack and other local apps. That avoided the interference, but did not give the terminal a convenient path to paste.

I restored write-back with both the image and the text reference. I also changed how the clipboard items were written after Universal Clipboard picked the path instead of the image on my iPhone. The watcher also had to avoid seeing its own clipboard update as a new screenshot and starting another sync.

The daemon checks for an active outgoing SSH session before syncing. That keeps ordinary image copies from triggering transfers when there is no remote session to use them.

What changed

I now run Claude Code locally and give it SSH access to the dev server. Claude can read the screenshot from my Mac directly, so I no longer need or use cpssh.

Keyboard shortcuts

/
Search
ga
About
gp
Projects
gb
Blog
ge
Experience
gc
Contact
help
Terminal commands in search
t
Switch theme
?
This panel
Esc
Close or clear