Linux环境下远程桌面共享工具之rdesktop安装及使用
简介
rdesktop 是 linux 下支持 Windows远程桌面连接的客户端程序,在 linux 系统下可通过它远程访问Windows 桌面,支持多种版本。rdesktop 是 sourceforge 下支持 GPL 协议的一个开源项目,采用 RDP(Remote Desktop Protocol,远程桌面协议),几乎可以连接 windows 的所有版本,诸如 NT 4 Terminal Server, 2000, XP, 2003, 2003 R2, Vista, 2008, 7, and 2008 R2 等。目前,rdesktop 可运行于所有的基于 X window 平台的 Unix 系统中。
rdesktop也可以用于连接远程的linux桌面。
1 rdesktop -u root -p lhr 172.17.0.2
参数:
-d: 域
-s: shell命令 (登录运行命令之后就退出)
-c: 工作目录(应该是-s的子命令),-s shell命令的一个参数
-p: password (- to prompt)
-n: 客户端(本地)主机名,默认为本地主机名
-k: 服务器上的键盘布局选择 (en-us, de, sv, etc.)
-g: 桌面分辨率(宽x高),使用 -g workarea 可自适应铺满当前 linux 窗口大小
-i: enables smartcard authentication, password is used as pin
-f: 全屏模式(Ctrl + Alt + Enter 退出全屏模式)
-b: 强制位图刷新(没发现什么用)
-L: 本地编码
-A: 无缝虚拟应用程序到本地
-B: use BackingStore of X-server (if available)
-e: disable encryption (French TS) 禁用加密
-E: disable encryption from client to server 从客户端到服务器,禁用加密。
-m: 不允许拖动(不传递鼠标的拖动事件)
-C: use private colour map
-D: 不显示窗口标题栏(只有远程桌面窗口,没有关闭和最小化按钮)
-K: 窗口切换快捷热键(Alt+Tab)不传递到远程桌面
-S: 标题按钮的大小,个人觉得这个参数很无用,或者我还没弄明白到底什么意思。
-T: 窗口标题
-t: disable use of remote ctrl
-N: 数字键盘同步
-X: 给定另一个窗口的标识,嵌入到另一个窗口
-a: connection colour depth 选择颜色深度
-z: 启用rdp压缩
-x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex nr.)
-P: 持久位图缓存
-r: 设备重定向(参数可以重复使用)
安装和使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | -- Ubuntu直接安装 apt-get install -y libx11-dev rdesktop -- arch/manjaro: sudo pacman -S rdesktop -- rdesktop 编译安装 yum install gcc-c++ ibX11-devel libXcursor libXcursor-devel libXrandr-devel libtasn1-devel nettle-devel gnutls-devel pcsc-lite-devel -y wget https://github.com/rdesktop/rdesktop/releases/download/v1.9.0/rdesktop-1.9.0.tar.gz tar -xzvf rdesktop-1.9.0.tar.gz cd rdesktop-1.9.0/ ./configure make && make install -- 使用 rdesktop -u administrator -p lhr 192.168.66.88 -- 域环境 rdesktop -d -u administrator -p lhr 192.168.66.88 -- 共享剪贴板和映射linux的/soft目录 rdesktop -u administrator -p lhr 192.168.66.236 -r disk:myshare=/soft -r clipboard:PRIMARYCLIPBOARD |
连接远程的Windows桌面:
连接远程的Linux桌面:
使用
样例:
1 | rdesktop -u username -p password IP -r sound:on/off -g 1024*768 |
1、username 和 password 分别是目标电脑的帐号和密码;
2、IP 为目标电脑的 IP 地址(可能需要先连接 VPN);
3、sound:on 表示传送目标电脑的声音,off 则为关闭;
4、-g 后接想要显示的分辨率
以上,除了用户名、密码和 IP 必须输入,其他参数都可以缺省。
更多参数:
5、使用 -f 参数进入全屏模式,中途可使用Ctrl+Alt+Enter组合键退出全屏;
6、-r disk:share_name=/local-disk
将本地磁盘映射到远程电脑,其中share_name为显示名称,可自定义,local-disk 表示本地 linux 的一个目录,比如 /data。
7、-r clipboard:PRIMARYCLIPBOARD
允许在远程主机和本机之间共享剪切板,就是可以复制粘贴。
以上是 rdesktop 的常用参数,更多参数请自行百度或者在 linux 中执行 rdesktop --help 查看。
编译报错问题
问题:configure: error: no acceptable C compiler found in $PATH
原因以及解决方法:没有安装合适的GCC编译器,执行sudo yum install gcc-c++
即可。
问题:ERROR: Could not find X Window System headers/libraries.
原因以及解决方法:没有安装libX11-devel软件包,执行yum install libX11-devel -y
即可。
问题:CredSSP support requires GSSAPI, install the dependency or disable the feature using --disable-credssp
此问题未解决,因为我实在是没找到关于GSSAPI怎么配置依赖,所以无奈之下执行了--disable-credssp
,如果有大佬知道怎么解决,麻烦评论区告诉我一下。
问题:rdesktop requires libXcursor, install the dependency
原因以及解决方法:没有安装libXcursor、libXcursor-devel、libXrandr-devel软件包,执行yum install libXcursor libXcursor-devel libXrandr-devel -y
即可(就这个破问题折腾了我一个小时,似乎在centos上100%会触发此问题)
问题:rdesktop requires libtasn1. Please install the dependency
原因以及解决方法:没有安装libtasn1-devel软件包,执行yum install libtasn1-devel
即可
问题:rdesktop requires Nettle. Please install the dependency
原因以及解决方法:没有安装nettle-devel软件包,执行yum install nettle-devel -y
问题:rdesktop requires GnuTLS. Please install the dependency
原因以及解决方法:没有安装gnutls-devel软件包,执行yum install gnutls-devel
问题:SmartCard support requires PCSC, install the dependency or disable the feature using --disable-smartcard.
原因以及解决方法:没有安装pcsc-lite-devel软件包,执行yum install pcsc-lite-devel
登陆报错
在Linux环境远程连接到Windows环境报错:
1 2 3 | Core(warning): Certificate received from server is NOT trusted by this system, an exception has been added by the user to trust this specific certificate. Failed to initialize NLA, do you have correct Kerberos TGT initialized ? Failed to connect, CredSSP required by server (check if server has disabled old TLS versions, if yes use -V option). |
原因分析:
在此之前需要让Windows支持远程协助,可以在系统属性-远程中开启:【允许远程协助连接这台计算机】(非必须)+【允许远程连接到此计算机】,如果勾选了【仅允许运行使用网络界别身份验证的远程桌面的计算机连接(建议)(N)】,那么 rdesktop 无法连接,报错信息如上。
也可以如下配置:
解决方法有两种:
1)不勾选【仅允许运行使用网络界别身份验证的远程桌面的计算机连接(建议)(N)】
2)使用 xfreerdp,请参考:https://www.xmmup.com/linuxhuanjingxiayuanchengzhuomiangongxianggongjuzhixfreerdpanzhuangjishiyong.html
总结
1、rdesktop可以连接远程的Windows桌面
2、rdesktop也可以连接远程的Linux桌面
3、在Linux环境中,rdesktop、xfreerdp和remminad都可以远程连接linux和windows环境,而在Windows环境中的mstsc远程桌面也可以连接远程的linux和windows环境