✅【超实用】一键解锁SSH远程Claude Code快捷键粘贴图片 ——Windows版本

2026-04-11 13:481阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

最近折腾了一个很实用的小方案,看到站里也有类似的困扰,正好今天有空,写篇教程填一下坑:

问题:我本地是 Windows,Claude Code 跑在远程 Linux 上。截图明明在我本地剪贴板里,但 AI 在远程机上,默认根本看不到。

claude code 服务器远程开发, 如何粘贴图片,直接粘贴提示 you're SSH'd; try scp 开发调优
我之后发个帖子吧,我是windows的,我写了个ps1的命令,然后绑定了快捷键,截图的时候snipaste会复制到粘贴板,然后你绑定快捷键我是ctrl+art+s,通过cursor的port转发,自动上传到你的服务器上的指定文件夹。然后claude code中用copy能自动读取指定文件夹最新的图片。我设定了一个skills叫/screenshot x,x是图片的个数。这样你windows也不用开…

对了,如果你没有耐性看完一下的内容,你可以直接使用这份提示词,丢给你的Claude Code, Antigravity, Cursor, etc.,让他们帮你操作。

For Human, Paste this into your LLM agent session (Claude Code, Antigravity, Cursor, etc.):

Install the remote-screenshot workflow by following: remote-screenshot-agent-install.txt

remote-screenshot-agent-install.txt (5.4 KB)

思路

→ Snipaste 截图 → PowerShell 从剪贴板取图 → 保存成 PNG → scp 上传到远程 ~/clipboard-images/ → ssh 更新 latest.png 软链接 → Claude Code 用 /screenshot 读图

最终达到的方案

  1. 截图后按热键
  2. 脚本把图片传到远程
  3. 远程 latest.png 被更新到最新图片
  4. 本地剪贴板被改成这张图的远程路径,比如
    /home/<YOUR_REMOTE_USER>/clipboard-images/clip_20260316_123456.png
  5. 在终端里右键粘贴时,贴进去的是这个图片路径
  6. Claude Code 看到这个绝对路径后,就能直接读取图片

image1616×210 9.21 KB

1. 远程服务器配置

先在远程机器上建一个目录,用来存截图:mkdir -p ~/clipboard-images

2. 配置 /screenshot 命令

在远程机器上创建文件:~/.claude/commands/screenshot.md
screenshot.txt (460 字节)
image1184×425 25.1 KB

这样你以后在 Claude Code 里就可以直接用:/screenshot 或 /screenshot 3

3. 本地 Windows脚本

在本地创建脚本,例如:C:\Scripts\Send-ClipboardImage.ps1

主要做的事情:
image554×236 16.5 KB

Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # ===== Configuration ===== $RemoteUser = "<YOUR_REMOTE_USER>" $RemoteHost = "<YOUR_REMOTE_HOST_OR_SSH_ALIAS>" $RemotePath = "/home/<YOUR_REMOTE_USER>/clipboard-images" # ========================= $img = [System.Windows.Forms.Clipboard]::GetImage() if (-not $img) { [System.Windows.Forms.MessageBox]::Show("剪贴板中没有图片", "提示", "OK", "Warning") exit 1 } $timestamp = Get-Date -Format "yyyyMMdd_HHmmss" $filename = "clip_${timestamp}.png" $tempDir = Join-Path $env:TEMP "clipboard-images" if (-not (Test-Path $tempDir)) { New-Item -ItemType Directory -Path $tempDir | Out-Null } $localPath = Join-Path $tempDir $filename $img.Save($localPath, [System.Drawing.Imaging.ImageFormat]::Png) $img.Dispose() scp $localPath "${RemoteUser}@${RemoteHost}:${RemotePath}/" if ($LASTEXITCODE -ne 0) { [System.Windows.Forms.MessageBox]::Show("SCP 传输失败,请检查 SSH 连接", "错误", "OK", "Error") exit 1 } ssh "${RemoteUser}@${RemoteHost}" "ln -sf ${RemotePath}/${filename} ${RemotePath}/latest.png" if ($LASTEXITCODE -ne 0) { [System.Windows.Forms.MessageBox]::Show("latest.png 更新失败,请检查远程路径或 SSH 权限", "错误", "OK", "Error") exit 1 } # 默认写回本次上传文件的绝对路径,方便在终端里右键直接粘贴给 Claude Code。 $remoteFull = "${RemotePath}/${filename}" Set-Clipboard -Value $remoteFull # 如果你更希望每次都粘贴固定路径,可以改成下面这一行: # Set-Clipboard -Value "${RemotePath}/latest.png" $notify = New-Object System.Windows.Forms.NotifyIcon $notify.Icon = [System.Drawing.SystemIcons]::Information $notify.BalloonTipTitle = "截图已发送" $notify.BalloonTipText = $remoteFull $notify.Visible = $true $notify.ShowBalloonTip(2000) Start-Sleep -Milliseconds 2500 $notify.Dispose()

你只要把下面三项换成自己的:

$RemoteUser = "你的远程用户名" $RemoteHost = "你的服务器 IP 或 SSH Host 别名" $RemotePath = "/home/你的远程用户名/clipboard-images"

4. 热键绑定

直接做一个 Windows 快捷方式:

目标写成:

powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Scripts\Send-ClipboardImage.ps1"

image1224×861 22.8 KB
image1224×861 16.1 KB
image840×973 24.3 KB

然后:

  1. 右键快捷方式 → 属性
  2. 设置快捷键,比如 Ctrl + Alt + S
  3. 把快捷方式丢到:C:\Users<用户名>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

如果被安全软件拦了!!请你想办法给他白名单!!!【注意:这个ps1脚本绝对安全,没有任何操作和后门,不放心就让AI模型分析一下】

5. 使用方式

方式 A:最省事

/screenshot

直接看 latest.png

方式 B:更自由

把刚才右键贴出来的路径直接放进提问里:

这个报错你帮我看下:/home/<YOUR_REMOTE_USER>/clipboard-images/clip_20260316_123456.png

这时候 Claude Code 会直接读取这张图。

6. 自动清理截图

不想目录越堆越大,可以在远程加个 cron:

0 4 * * * find ~/clipboard-images -name "clip_*.png" -mtime +7 -delete

花费了3h写这个教程,给个赞!哈哈哈哈哈!!!

试试看会不会有免费的赞助哈哈哈,有没有好心人,5LDC​

credit.linux.do

LINUX DO Credit

网友解答:
--【壹】--:

太强了,大佬


--【贰】--:

后续如果觉得绑定快捷键步骤太麻烦,可以让claude安装一个插件。我忘了叫啥了,会方便点。但我这个是最小化实现哈哈哈。也很好用


--【叁】--:

测试了下, 确实好用, 感谢分享~


--【肆】--:

都用得了哦


--【伍】--:

感谢分享,一直以为图片直接上传就完了,原来实现起来这么麻烦啊


--【陆】--:

因为要追求无感哈哈哈哈


--【柒】--:

用了,win 的快捷方式貌似要放到桌面才能让快捷键触发(我试着是这样)。运行方式选最小化就不会有黑色的弹框了


--【捌】--:

高手!!! 谢谢大佬!


--【玖】--:

思路不错


--【拾】--:

嗯嗯,感谢补充


--【拾壹】--:

我目前的方案非常稳定,你可以试试看,基本上适用于任何环境。mac没试过,但逻辑差不多


--【拾贰】--:

佬,SSH软件是不是用不了,比如termius


--【拾叁】--:

先收藏,后使用!


--【拾肆】--:

我现在是通过ssh转发x11 server,直接用默认的ctrl+v就能粘贴,但有时候会失效,需要重新启动会话


--【拾伍】--:

正好有在vscode ssh里用cc的需求,十分感谢!!


--【拾陆】--:

感谢分享


--【拾柒】--:

前排支持,感谢佬友分享


--【拾捌】--:

CC+MINIMAX 的情况下需要使用 MINIMAX 的 MCP,这就需要调整下 command 的提示词:

Read screenshot images from ~/clipboard-images/. First run `ls -lt ~/clipboard-images/*.png | head -10` to see recent files. If the user specifies a number (e.g. "/screenshot 3" or "/screenshot latest 3"), read the N most recent .png files (by modification time) using the `mcp__MiniMax__understand_image` tool. If no number is specified, read only ~/clipboard-images/latest.png. For each image, call: mcp__MiniMax__understand_image( prompt="Please describe this image in detail, including any text, UI elements, data, code, or other content visible. Include full code if present.", image_source="" ) After reading, describe what you see in each image and answer any question the user provides.