Skip to content

feat(macos): add SSH image paste support#10515

Closed
mvanhorn wants to merge 1 commit intoghostty-org:mainfrom
mvanhorn:feat/ssh-image-paste
Closed

feat(macos): add SSH image paste support#10515
mvanhorn wants to merge 1 commit intoghostty-org:mainfrom
mvanhorn:feat/ssh-image-paste

Conversation

@mvanhorn
Copy link
Copy Markdown

@mvanhorn mvanhorn commented Feb 1, 2026

Closes #10516

Summary

When pasting an image from the clipboard while in an SSH session, Ghostty now automatically uploads the image to the remote host via SCP and inserts the remote file path instead.

This enables seamless image sharing with remote tools like Claude Code that can read local files but not the local clipboard.

How it works

  1. User copies image to clipboard
  2. User presses Ctrl+V in SSH session
  3. Ghostty detects image data + finds active SSH ControlMaster socket
  4. Image uploads via SCP to /tmp/ghostty-paste-{uuid}.png on remote
  5. Remote path is inserted as text

Uses existing SSH ControlMaster sockets for authentication - no password prompts.

Changes

  • macos/Sources/Helpers/SSHImagePaste.swift - Core upload logic (280 lines)
  • macos/Sources/Helpers/Extensions/NSPasteboard+Extension.swift - Image detection
  • macos/Sources/Ghostty/Ghostty.App.swift - Integration in clipboard handling
  • src/config/Config.zig - Config options

Config options

ssh-image-paste = true          # Enable/disable feature (default: true)
ssh-image-paste-path = /tmp     # Remote upload directory (default: /tmp)

Test plan

  • Copy image to clipboard, paste in SSH session → path appears
  • Paste text in SSH session → normal behavior
  • Paste when not in SSH → graceful fallback
  • Works with Claude Code on remote host

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

When pasting an image from the clipboard while in an SSH session,
automatically upload the image to the remote host via SCP and insert
the remote file path instead.

This uses SSH ControlMaster sockets for authentication, so it works
seamlessly with existing SSH connections without password prompts.

Features:
- Auto-detect active SSH ControlMaster sockets
- Upload clipboard images to /tmp/ on remote host
- Insert remote path as text for tools like Claude Code
- Graceful fallback when not in SSH session

Config options (in src/config/Config.zig):
- ssh-image-paste: bool (default: true)
- ssh-image-paste-path: string (default: /tmp)

Co-Authored-By: Claude <noreply@anthropic.com>
@mvanhorn mvanhorn requested a review from a team as a code owner February 1, 2026 05:14
@rhodes-b
Copy link
Copy Markdown
Member

rhodes-b commented Feb 1, 2026

as noted by the AI policy, any AI assisted PRs need to be an accepted issue not random PRs
https://github.com/ghostty-org/ghostty/blob/main/AI_POLICY.md

Pull requests created in any way by AI can only be for accepted issues. Drive-by pull requests that do not reference an accepted issue will be closed. If AI isn't disclosed but a maintainer suspects its use, the PR will be closed. If you want to share code for a non-accepted issue, open a discussion or attach it to an existing discussion.

@mitchellh
Copy link
Copy Markdown
Contributor

Closing this due to violating our policies. I converted your issue to a discussion, as the guidelines also suggest. There was a lot of failure to read the instructions here which is highly questionable, but I will review your discussion in due time.

@mitchellh mitchellh closed this Feb 1, 2026
@mvanhorn
Copy link
Copy Markdown
Author

mvanhorn commented Feb 1, 2026

Thanks for the feedback @mitchellh and @Brice-W!

I looked into OSC 5522 and you're right - that's the proper way to solve this. My SCP/ControlMaster approach works but it's definitely a hack compared to having native terminal protocol support for typed clipboard data.

The OSC 5522 protocol handles:

  • MIME types (not just PNG)
  • Chunked transfer for large payloads
  • Works over SSH natively (just escape codes through PTY)
  • Built-in security model with passwords/confirmations
  • Cross-platform in the terminal core

I'd be happy to help implement OSC 5522 in Ghostty if that would be useful. I could start by:

  1. Reading/writing with MIME type support in the Zig core
  2. Adding the clipboard permission flow for typed data
  3. Supporting the paste event mode (Private Mode 5522)

Let me know if this is something you'd want help with, or if there's already work in progress. Happy to close this PR since OSC 5522 is the better path forward.

@arielweinberger
Copy link
Copy Markdown

I'm seeing that both the PR and #10516 were closed without any additional comments... Still seems to be broken. Is there any plan to support this? @mitchellh

@rhodes-b
Copy link
Copy Markdown
Member

rhodes-b commented May 7, 2026

I'm seeing that both the PR and #10516 were closed without any additional comments... Still seems to be broken. Is there any plan to support this? @mitchellh

Given multiple contribution guidelines were not followed thats why it was closed without anything further. Mitchell explained the next step (make a discussion)

This also is not "broken" as it was never a feature and its a hack to scp a file over ssh when you detect its a image there are real protocols for this like osc5522 (which has a discussion) which lers remote hosts copy from and to the clipboard multiple datatypes (not plain text)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: SSH image paste support

4 participants