windows与linux之间通过远程桌面接入时,如何CTRL+C CTRL + V,频繁ctrl c v

windows与linux之间通过远程桌面接入时,如何CTRL+C  CTRL + V,以下是几种方案的实现方法:(以ubuntu为例子)

方案一:使用RDP协议(推荐)

1. Ubuntu作为服务器,Windows远程连接

Ubuntu端配置:

bash
# 安装xrdp
sudo apt update
sudo apt install xrdp

# 安装xorgxrdp以改进剪贴板支持
sudo apt install xorgxrdp

# 启动服务
sudo systemctl enable --now xrdp

# 允许防火墙
sudo ufw allow 3389/tcp

Windows端配置:

  1. 使用Windows自带的"远程桌面连接"

  2. 连接时选择"显示选项" → "本地资源" → "剪贴板"

  3. 确保"剪贴板"选项已勾选

2. 增强剪贴板功能(双向支持)

bash
# Ubuntu端安装增强工具
sudo apt install xrdp-pulseaudio-installer

# 重启xrdp服务
sudo systemctl restart xrdp

3. 每次连接完成后,要主动断开连接,确保下次连接正常稳定

方案二:使用VNC协议

Ubuntu端配置:

bash
# 安装TigerVNC服务器
sudo apt install tigervnc-standalone-server tigervnc-xorg-extension

# 设置VNC密码
vncpasswd

# 安装剪贴板管理器
sudo apt install autocutsel

# 在启动脚本中添加剪贴板支持
# 编辑 ~/.vnc/xstartup,添加:
autocutsel -fork &
autocutsel -selection PRIMARY -fork &

windows端配置

下载vnc客户端接入ubuntu即可

方案三:使用NoMachine(推荐,体验最佳)

1. 下载安装

2. 配置剪贴板

  • 安装后默认剪贴板功能通常已经启用

  • 如需调整:连接 → 设置 → 剪贴板 → 启用双向剪贴板

方案四:使用AnyDesk/TeamViewer

AnyDesk配置:

  1. 双方安装AnyDesk

  2. 连接后点击顶部菜单 → 动作 → 剪贴板同步

  3. 启用"发送本地剪贴板"和"接收远程剪贴板"

常见问题解决

1. RDP剪贴板不工作

bash
# Ubuntu端检查剪贴板服务
ps aux | grep xrdp-chansrv

# 如果没有运行,手动启动
sudo /usr/local/sbin/xrdp-chansrv

2. 权限问题

bash
# 确保用户有足够权限
sudo usermod -a -G ssl-cert $USER

3. 重启剪贴板服务

bash
# RDP重启服务
sudo systemctl restart xrdp

# 或者重新登录RDP会话

优化配置

RDP高级配置(编辑/etc/xrdp/xrdp.ini):

ini
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=high
channel_code=1
max_bpp=32
use_compression=yes

# 确保剪贴板通道启用
enable_channels=true
channel.rdpdr=true
channel.rdpsnd=true
channel.drdynvc=true
channel.cliprdr=true

防火墙设置:

bash
# Ubuntu防火墙规则
sudo ufw allow from any to any port 3389

测试方法

  1. 基础测试:

    • 在Ubuntu复制文本 → 在Windows粘贴

    • 在Windows复制文件 → 在Ubuntu粘贴(如果支持)

  2. 高级测试:

    bash
    # Ubuntu端检查剪贴板内容
    xclip -selection clipboard -o
    
    # Windows端可用Powershell测试
    Get-Clipboard

最佳实践建议

  1. 方案选择优先级:

    • NoMachine(性能最好)

    • RDP(微软原生,稳定性好)

    • VNC(兼容性好)

  2. 网络优化:

    • 使用有线网络连接

    • 确保端口正确开放

    • 调整显示质量以提高响应速度

  3. 安全建议:

    • 使用强密码

    • 考虑使用VPN或SSH隧道

    • 养成良好使用习惯

选择哪种方案取决于你的具体需求:RDP适合Windows-Ubuntu混合环境,NoMachine提供最完整的剪贴板体验,VNC则是最通用的跨平台解决方案。

 以上DS推荐攻略
 

频繁使用windows剪贴板有几种快捷方法可以将 Windows 10 中的复制的内容到 Ubuntu  中:

方法一:使用共享剪贴板工具(推荐)

1. 安装共享剪贴板工具

在 Ubuntu 中安装 xclip 和配置共享:

bash
# Ubuntu 安装
sudo apt update
sudo apt install xclip xsel

# Windows 安装 Win32-OpenSSH 并启用 SSH 服务

2. 使用 Synergy/Barrier(图形界面共享)

  • 在 Windows 和 Ubuntu 都安装 Barrier

  • 配置服务器(Ubuntu)和客户端(Windows)

  • 可以直接跨系统复制粘贴文本

方法二:通过 SSH 快速传输

1. 设置 SSH 密钥认证

bash
# 在 Ubuntu 生成密钥
ssh-keygen -t rsa

# 复制公钥到 Windows
ssh-copy-id user@windows-ip

2. 创建快捷脚本

在 Ubuntu 的 ~/.bashrc 中添加:

bash
# 从 Windows 获取剪贴板内容
alias get-win-clip="ssh user@windows-ip 'powershell Get-Clipboard'"

方法三:使用 Python 脚本

Windows 端脚本(save_clipboard.py):

python
import pyperclip
with open('clipboard.txt', 'w') as f:
    f.write(pyperclip.paste())

通过 scp 传输:

bash
# 从 Windows 复制到 Ubuntu
scp user@windows-ip:/path/clipboard.txt /tmp/
cat /tmp/clipboard.txt | xclip -selection clipboard

方法四:直接使用 VS Code 远程功能

1. 安装 VS Code Remote - SSH 扩展

  • 在 VS Code 中安装 Remote Development 扩展包

2. 连接到 Ubuntu

  • 按 F1 → "Remote-SSH: Connect to Host"

  • 输入 Ubuntu 的 SSH 连接信息

3. 直接操作

连接后,可以直接在 Windows 的 VS Code 中操作 Ubuntu 文件,复制粘贴无缝进行。

方法五:快速命令行方法

一次性命令:

bash
# 将 Windows 剪贴板内容发送到 Ubuntu 文件
ssh user@windows-ip "powershell Get-Clipboard" > ~/project/url.txt

# 或者直接插入到 VS Code打开的文件
echo "https://deepseek.com" | ssh ubuntu-user@ubuntu-ip "cat >> /path/to/file"

最快捷的实际操作:

  1. 在 Windows 复制网址(Ctrl+C)

  2. 在 Ubuntu 终端执行:

bash
# 如果已经配置了 SSH 密钥
ssh windows-user@windows-ip "powershell Get-Clipboard" | xclip -selection clipboard
  1. 在 Ubuntu VS Code 中粘贴(Ctrl+V)

建议:

  • 对于频繁操作,推荐使用方法一(Barrier)或方法四(VS Code Remote)

  • 对于偶尔使用,方法五的命令行方式最简单

 

 
 
posted @ 2025-12-03 10:39  zhg1016  阅读(20)  评论(0)    收藏  举报