赞
踩
您多久访问一次Linux桌面? 您使用什么工具来访问远程桌面?
Xrdp是一个开源工具,允许用户通过Windows RDP访问Linux远程桌面。 除了Windows RDP之外,xrdp工具还接受来自其他RDP客户端的连接,如FreeRDP,rdesktop和NeutrinoRDP。 Xrdp现在支持TLS安全层。
Xrdp要求
在本文中,我将展示如何使用Xrdp工具从Windows机器远程连接到Ubuntu桌面。
首先,您需要在Ubuntu上安装Xrdp
apt install xrdp
您必须配置polkit规则以避免在Windows上的xrdp登录屏幕上输入用户名和密码后进行身份验证弹出窗口
linuxidc@linuxidc:~$ sudo nano /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf
polkit.addRule(function(action, subject) {
if ((action.id == “org.freedesktop.color-manager.create-device” || action.id == “org.freedesktop.color-manager.create-profile” || action.id == “org.freedesktop.color-manager.delete-device” || action.id == “org.freedesktop.color-manager.delete-profile” || action.id == “org.freedesktop.color-manager.modify-device” || action.id == “org.freedesktop.color-manager.modify-profile”) && subject.isInGroup(“{group}”))
{
return polkit.Result.YES;
}
});
重启xrdp服务
linuxidc@linuxidc:~$ sudo systemctl restart xrdp
然后确保该服务正在运行
linuxidc@linuxidc:~$ systemctl status xrdp
● xrdp.service - xrdp daemon
Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: ena
Active: active (running) since Mon 2018-10-29 21:16:31 CST; 2min 0s ago
Docs: man:xrdp(8)
man:xrdp.ini(5)
Process: 5543 ExecStop=/usr/sbin/xrdp $XRDP_OPTIONS --kill (code=exited, statu
Process: 5565 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS (code=exited, status=0/SU
Process: 5557 ExecStartPre=/bin/sh /usr/share/xrdp/socksetup (code=exited, sta
Main PID: 5566 (xrdp)
Tasks: 1 (limit: 2305)
Memory: 1.2M
CGroup: /system.slice/xrdp.service
└─5566 /usr/sbin/xrdp
现在确保在系统启动时自动启动服务
linuxidc@linuxidc:~$ systemctl enable xrdp
Synchronizing state of xrdp.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable xrdp
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
Failed to reload daemon: Message recipient disconnected from message bus without replying
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
Failed to reload daemon: Message recipient disconnected from message bus without replying
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
Failed to enable unit: Message recipient disconnected from message bus without replying
现在您需要检查您的IP地址,因为您将需要它来进行连接
linuxidc@linuxidc:~$ ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:e4:b3:cf brd ff:ff:ff:ff:ff:ff
inet 192.168.182.146/24 brd 192.168.182.255 scope global dynamic noprefixroute ens33
valid_lft 1116sec preferred_lft 1116sec
inet6 fe80::3f83:c7da:950a:e08/64 scope link noprefixroute
valid_lft forever preferred_lft forever
我的IP地址是192.168.182.146。 所以请记住。
Xrdp使用端口3389,所以一定要打开它。 默认情况下禁用UFW,因此您需要启用防火墙并为xrdp创建规则
linuxidc@linuxidc:~$ sudo ufw enable
[sudo] linuxidc 的密码:
在系统启动时启用和激活防火墙
linuxidc@linuxidc:~$ sudo ufw allow 3389/tcp
规则已添加
规则已添加 (v6)
如果这时候出现所说的Ubuntu安中装的xrdp,桌面共享设置为允许,虚拟机设置的是桥接,虚拟机内外可以互相ping 通;
在Windows下用 mstsc 连接Ubuntu桌面,跳出账号密码页面,登录后自动退出(闪退)的解决方法:
sudo apt-get install xfce4
echo xfce4-session > ~/.xsession
touch .session
sudo vim /etc/xrdp/startwm.sh
在. /etc/X11/Xsession前面加
xfce4-session
然后重启 sudo service xrdp restart。
现在,您可以在Windows端继续配置。
确保之前安装了Epel存储库
# rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
现在安装xrdp包
# yum update && yum -y install xrdp tigervnc-server
在防火墙中添加规则。 CentOS/RedHat不是ufw,而是firewalld来配置
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=3389/tcp
success
然后重新加载防火墙
[root@localhost ~]# firewall-cmd --reload
success
现在启用并重新启动xrdp服务
[root@localhost ~]# systemctl enable xrdp && systemctl restart xrdp
Created symlink from /etc/systemd/system/multi-user.target.wants/xrdp.service to /usr/lib/systemd/system/xrdp.service.
检查您的IP地址以获取Windows上的远程连接
[root@localhost ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:93:77:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.182.148/24 brd 192.168.182.255 scope global noprefixroute dynamic ens33
valid_lft 1285sec preferred_lft 1285sec
inet6 fe80::72bf:712e:7c0b:ca6d/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:02:67:f9 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:02:67:f9 brd ff:ff:ff:ff:ff:ff
在我们的Windows机器上,例如Windows 10,启动默认的远程桌面连接工具。
输入IP地址和用户名
您需要输入机器的IP地址,系统会要求您输入用户名
Ubuntu上的
访问CentOS的远程桌面
现在确认信息并启动连接。 如果您未在本地注销,则远程登录将失败。现在您将被要求输入密码
现在确认您的凭据。 您可以在顶部和登录页面上看到我的Ubuntu的IP地址, 输入您的密码连接。
如果你知道还有他工具, 请在评论里告知我们。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。