首页 > 系统相关 >如何在CentOS7 安装 XRDP 远程桌面服务器

如何在CentOS7 安装 XRDP 远程桌面服务器

时间:2023-12-07 16:32:29浏览次数:44  
标签:VNC GNOME XRDP Desktop CentOS7 etc yum 远程桌面 安装

1)图形界面安装

CentOS7 没有图形化操作可能对很多人来说都不太习惯,下面我们来为 CentOS7 安装图形化界面,本文以安装 GNOME 图形化为例

**写在安装前: **如果你的 CentOS7 是最小化安装,默认都是不带 XWINDOWS 的

  1. 配置公网 Yum
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup

cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/ 
        https://mirrors.huaweicloud.com/centos/\$releasever/os/\$basearch/ 
        https://mirrors.cloud.tencent.com/centos/\$releasever/os/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/os/\$basearch/
        http://mirrors.163.com/centos/\$releasever/os/\$basearch/
        http://mirrors.sohu.com/centos/\$releasever/os/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever

[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
        https://mirrors.huaweicloud.com/epel/\$releasever/\$basearch/
        https://mirrors.cloud.tencent.com/epel/\$releasever/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/epel/\$releasever/\$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-\$releasever

[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/
        https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/
        http://mirrors.163.com/centos/\$releasever/extras/\$basearch/
        http://mirrors.sohu.com/centos/\$releasever/extras/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever

[updates]
name=updates
baseurl=https://mirrors.aliyun.com/centos/\$releasever/updates/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/updates/\$basearch/
        https://mirrors.cloud.tencent.com/centos/\$releasever/updates/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/updates/\$basearch/
        http://mirrors.163.com/centos/\$releasever/updates/\$basearch/
        http://mirrors.sohu.com/centos/\$releasever/updates/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever

[centosplus]
name=centosplus
baseurl=https://mirrors.aliyun.com/centos/\$releasever/centosplus/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/centosplus/\$basearch/
        https://mirrors.cloud.tencent.com/centos/\$releasever/centosplus/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/centosplus/\$basearch/
        http://mirrors.163.com/centos/\$releasever/centosplus/\$basearch/
        http://mirrors.sohu.com/centos/\$releasever/centosplus/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
EOF

yum clean all
yum repolist

输入安装 GNOME Desktop 命令

// < '桌面二选一' >
1. yum groupinstall -y "GNOME Desktop" 	# GNOME DESKTOP
2. yum groupinstall -y "MATE Desktop"		# MATE DESKTOP

image.png

安装完毕后,需要 设置默认从图形化界面启动

// 设置成图形模式
systemctl set-default graphical.target  

重启系统

reboot

2)VNC 服务安装

Linux 系统在服务器上一般都直接最小化安装,并未安装图形界面,但是有时候,有一些特殊情况,需要使用图形界面。< 当然,其实我们也可以直接通过 XServer 转发至 Windows 显示 > 下面我将利用 VNC 来实现类似 Windows 的远程桌面功能。

首先,系统需要有图形界面,可以在安装系统的时候一起安装 GNOME,或者后面再安装也行,下面即安装方法。

  1. 配置公网 Yum 源
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup

cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/ 
        https://mirrors.huaweicloud.com/centos/\$releasever/os/\$basearch/ 
        https://mirrors.cloud.tencent.com/centos/\$releasever/os/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/os/\$basearch/
        http://mirrors.163.com/centos/\$releasever/os/\$basearch/
        http://mirrors.sohu.com/centos/\$releasever/os/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever

[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
        https://mirrors.huaweicloud.com/epel/\$releasever/\$basearch/
        https://mirrors.cloud.tencent.com/epel/\$releasever/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/epel/\$releasever/\$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-\$releasever

[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/
        https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/
        http://mirrors.163.com/centos/\$releasever/extras/\$basearch/
        http://mirrors.sohu.com/centos/\$releasever/extras/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever

[updates]
name=updates
baseurl=https://mirrors.aliyun.com/centos/\$releasever/updates/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/updates/\$basearch/
        https://mirrors.cloud.tencent.com/centos/\$releasever/updates/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/updates/\$basearch/
        http://mirrors.163.com/centos/\$releasever/updates/\$basearch/
        http://mirrors.sohu.com/centos/\$releasever/updates/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever

[centosplus]
name=centosplus
baseurl=https://mirrors.aliyun.com/centos/\$releasever/centosplus/\$basearch/
        https://mirrors.huaweicloud.com/centos/\$releasever/centosplus/\$basearch/
        https://mirrors.cloud.tencent.com/centos/\$releasever/centosplus/\$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/centosplus/\$basearch/
        http://mirrors.163.com/centos/\$releasever/centosplus/\$basearch/
        http://mirrors.sohu.com/centos/\$releasever/centosplus/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
EOF

yum clean all
yum repolist
  1. 安装 GNOME 桌面
// 列出的组软件包列表
// < '桌面二选一' >
yum grouplist
yum groupinstall -y "GNOME Desktop"			// 安装 GNOME DESKTOP
yum groupinstall -y "MATE Desktop"			// 安装 MATE Desktop

# 安装完成后, 修改默认启动方式为图形化界面
// 设置成图形模式
systemctl set-default graphical.target  

# 如果要换回来
// 设置成命令模式
systemctl set-default multi-user.target  

然后重启即可。

  1. 安装 VNC SERVER
yum install tigervnc-server -y
  1. 将 root 用户的 VNC 端口 设置为 Service 服务
// 复制一个 Service 服务设置模板
cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service

// 修改此服务配置
# 以下为 root 用户的配置, 每一个用户, 都需要单独设置一个监听服务, 且配置不同
vim /etc/systemd/system/vncserver@\:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=root

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=-/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target
  1. 设置 VNC 密码,VNC 的密码跟系统的用户密码不一样,是使用 VNC 客户端登陆时需要使用的密码。
[root@localhost ~] vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n		# 这里不添加只读账号密码
A view-only password is not used
  1. 启动服务,验证端口
# 设为开机启动
systemctl start vncserver@:1
systemctl enable vncserver@:1

# 查看服务监听的端口
netstat -lnpt | grep Xvnc

# 根据监听的端口
# 进行端口开放
# 每个用户会对应一个端口, 第一个用户默认为 5901 端口, 我这里是 root 用户
firewall-cmd --add-port=5901/tcp --permanent
firewall-cmd --reload

image.png

  1. 到此 VNC 服务就已经安装完成了。然后需要使用 VNC 客户端进行连接。

image.png

**注意:MATE DESKTOP **桌面可能会出现如下状况

image.png

解决

< '解决' >
vim ~/.vnc/xstartup
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

/usr/bin/mate-session &

image.png

重启 ROOT 端口服务

systemctl restart vncserver@:1

image.png

完成 VNC 连接~

3)XRDP 服务安装

CentOS7 提供了 "Cinnamon Desktop""MATE Desktop""GNOME Desktop""KDE Plasma Workspaces""LXQt Desktop",**"Xfce" ** 让我们安装。

  1. 我们可以选择自己喜欢的桌面环境,在这里选择安装 MATE DESKTOP 桌面:
// < '桌面二选一' >
yum groupinstall Xfce -y
yum groupinstall "MATE Desktop" -y
  1. 安装 XRDP
yum -y install xrdp
  1. 安装完成之后,设置开机默认启动 XRDP
systemctl start xrdp 
systemctl enable xrdp

// 验证端口
netstat -nltp | grep 3389

image.png

  1. 创建 ~/.Xclients,设置默认启动 xfce4 桌面
// xfce Desktop
echo "xfce4-session" > ~/.Xclients
chmod +x .Xclients

// mate Desktop
echo "mate-session" > ~/.Xclients
chmod +x .Xclients
  1. 在 Windows 客户端远程连接

image.png

输入 **Linux 系统 **的账户认证

image.png image.png

大功告成~

标签:VNC,GNOME,XRDP,Desktop,CentOS7,etc,yum,远程桌面,安装
From: https://blog.51cto.com/blogking/8724487

相关文章

  • 物理机安装CentOS7
    准备阶段一个需要安装版本的iso镜像文件一个U盘一台物理机一台有windos系统的电脑制作启动盘下载UltraISO(收费搜一搜可以解决)写入硬盘映像先格式化,选择usb-hdd+v2写入可能会卡耐心等待安装系统插入u盘进入启动项选择页面选择UEFIU盘启动可能会出现u盘启动找不到的情况......
  • CentOS7安装Docker
    配置要求系统:Centos7Linux内核:官方建议3.10以上注意:本文的命令使用的是root用户登录执行,不是root的话所有命令前面要加sudo1.查看当前的内核版本uname-r2.更新yum包(使用root权限,生产环境中此步操作需慎重,耗时较长,该步骤可以跳过)yum-yupdateyum-yup......
  • CentOS7升级内核版本,以及解决升级内核后网卡不能使用的问题
    CentOS7.9自带的内核版本为3.1,没有wireguard模块,遂决定升级内核版本 第一步升级内核,参考https://www.cnblogs.com/iwalkman/p/9736856.html 除了内核还需要安装kernel-ml-devel,否则待会编译网卡驱动会报错yum--enablerepo=elrepo-kernelinstallkernel-ml-devel 我......
  • centos7安装Jenkins
    1、拉取镜像dockerpulljenkinsci/blueocean2、创建目录mkdir-p /home/data/jenkinschmod777 /home/data/jenkins3、启动容器dockerrun-d-p8099:8080-p50099:50000-v/home/data/jenkins:/var/jenkins_home--namemyjenkins--restart=alwaysjenkinsci/blueoce......
  • CentOS7 安装 Oracle12c 详解
    1.安装前准备中科大镜像站下载完整版CentOS7 Indexof/centos/7/isos/x86_64/(ustc.edu.cn)安装时设置硬盘大小40G,选择GNOME桌面安装,勾选必要的一些东西安装时选择只装root用户重启后要求配置一个用户,设置用户名为oracle下载历史版本Oracle数据库 https://edelivery.o......
  • centos7桌面版安装百度网盘
    百度网盘官网下载Linux版本的软件CentOS7的软件包格式为rpm#安装依赖yum-yinstalllibXScrnSaveryum-yinstalllibstdc++.so.6cd/usr/local/lib64#下载最新版本的libstdc.so_.6.0.26wgethttp://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zipu......
  • centos7.9以docker形式安装redmine,并配置
    一、准备准备服务器联网,并且安装好docker二、安装redmine执行命令拉取docker镜像dockerpullredmine:latestRunRedminewithSQLite3dockerrun-d--nameredmine-p3000:3000redmine:latest启动后访问:http://localhost:3000/,默认账号/密码:admin/admin  进入后......
  • RabbitMQ高可用集群的搭建部署(Centos7)
    高可用集群架构节点域名操作系统RabbitMQ版本Erlang版本iamdemo.tp-link.comCentos7.93.8.2823.3-2iamdemo2.tp-link.comCentos7.93.8.2823.3-2iamdemo3.tp-link.comCentos7.93.8.2823.3-2目前Centos7.9通过直接RPM包部署安装的版本最高支持到3.8.......
  • Centos7 防火墙开放端口,查看状态,查看开放端口
    CentOS7端口的开放关闭查看都是用防火墙来控制的,具体命令如下:查看防火墙状态:(active(running)即是开启状态)systemctlstatusfirewalld[root@WSSbin]#systemctlstatusfirewalld●firewalld.service-firewalld-dynamicfirewalldaemonLoaded:loaded......
  • centos7 docker-ce
    言Docker使用越来越多,安装也很简单,本次记录一下基本的步骤。Docker目前支持CentOS7及以后的版本,内核要求至少为3.10。Docker官网有安装步骤,本文只是记录一下,您也可以参考DockerCEInstallonCentOS环境说明CentOS7(MinimalInstall)$cat/etc/redhat-releaseCentOS......