##通过ssh方式连接CentOS
ssh -l root 192.168.10.200
##安装xrdp远程桌面协议
yum install xrdp -y
##安装epel仓库
yum install epel-release -y
##安装xrdp远程桌面协议
yum install xrdp -y
##启动xrdp
systemctl start xrdp
##xrdp设为开机启动
systemctl enable xrdp
##查看xrdp服务是否正常启动//如果看到Active则说明正常
systemctl status xrdp.service
##查看xrdp服务是否正常启动//看xrdp和xrdp-sesman是否正常启动
systemctl status xrdp.service
##
ss -antup|grep xrdp
##
gdmflexiserver --xnest
##安装vncserver
yum install tigervnc-server tigervnc-server-module
##安装vnc
yum install tigervnc-server tigervnc-server-module
##安装vncserver
rpm -q tigervnc tigervnc-server
##安装vncserver
rpm -q tigervnc tigervnc-server
##拷贝vncserver实例
cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
##配置vncserver实例
vim /etc/systemd/system/vncserver@:1.service
# vim /etc/systemd/system/vncserver@\:1.service
[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
##加载进程,重启服务
systemctl start vncserver@:1.service
systemctl enable vncserver@:1.service
systemctl enable vncserver@:1.service
vncserver
##
vi /etc/ssh/sshd_config
##配置系统防火墙
firewall-cmd --permanent --add-service vnc-server
firewall-cmd --zone=public --add-port=5901/tcp --permanent
firewall-cmd --reload
##
systemctl status vncserver@:1
##
vncserver -list
##
ps aux |grep vnc
发现服务器重启以后vnc服务没有启动,查了一下,解决方案如下:
\rm -R /tmp/.X11-unix/
vim /etc/systemd/system/vncserver@:1.service
systemctl daemon-reload
systemctl enable vncserver@:1.service
终端记录:
JiMideMacBook-Pro:~ jimi$ ssh -l root 192.168.10.200
The authenticity of host '192.168.10.200 (192.168.10.200)' can't be established.
ECDSA key fingerprint is SHA256:FcX9ekUVMkyel1k2X24FfARAEYSXmAQWaSFSK7PG/3M.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.10.200' (ECDSA) to the list of known hosts.
[email protected]'s password:
Last login: Thu May 16 20:07:05 2019
[root@localhost ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg perl5
[root@localhost ~]# cd ..
[root@localhost /]# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@localhost /]# cd usr
[root@localhost usr]# ls
bin etc games include lib lib64 libexec local sbin share src tmp
[root@localhost usr]# yum install xrdp -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.163.com
* updates: mirrors.163.com
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
gitlab_gitlab-ee/x86_64/signature | 836 B 00:00
gitlab_gitlab-ee/x86_64/signature | 1.0 kB 00:00 !!!
gitlab_gitlab-ee-source/signature | 836 B 00:00
gitlab_gitlab-ee-source/signature | 951 B 00:00 !!!
google-chrome | 1.3 kB 00:00
updates | 3.4 kB 00:00
没有可用软件包 xrdp。
错误:无须任何处理
[root@localhost usr]# yum install epel-release -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.163.com
* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
epel-release noarch 7-11 extras 15 k
事务概要
================================================================================
安装 1 软件包
总下载量:15 k
安装大小:24 k
Downloading packages:
epel-release-7-11.noarch.rpm | 15 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : epel-release-7-11.noarch 1/1
验证中 : epel-release-7-11.noarch 1/1
已安装:
epel-release.noarch 0:7-11
完毕!
[root@localhost usr]# yum install xrdp -y
已加载插件:fastestmirror, langpacks
/var/run/yum.pid 已被锁定,PID 为 11546 的另一个程序正在运行。
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存: 31 M RSS (478 MB VSZ)
已启动: Sat May 18 23:24:55 2019 - 00:04之前
状态 :睡眠中,进程ID:11546
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存: 31 M RSS (478 MB VSZ)
已启动: Sat May 18 23:24:55 2019 - 00:06之前
状态 :睡眠中,进程ID:11546
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存: 31 M RSS (478 MB VSZ)
已启动: Sat May 18 23:24:55 2019 - 00:08之前
状态 :睡眠中,进程ID:11546
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存: 33 M RSS (1.4 GB VSZ)
已启动: Sat May 18 23:24:55 2019 - 00:11之前
状态 :睡眠中,进程ID:11546
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存: 36 M RSS (1.4 GB VSZ)
已启动: Sat May 18 23:24:55 2019 - 00:13之前
状态 :运行中,进程ID:11546
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存:258 M RSS (1.6 GB VSZ)
已启动: Sat May 18 23:24:55 2019 - 00:15之前
状态 :睡眠中,进程ID:11546
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存:258 M RSS (1.6 GB VSZ)
已启动: Sat May 18 23:24:55 2019 - 00:17之前
状态 :睡眠中,进程ID:11546
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存:258 M RSS (1.6 GB VSZ)
已启动: Sat May 18 23:24:55 2019 - 00:19之前
状态 :睡眠中,进程ID:11546
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.163.com
* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 xrdp.x86_64.1.0.9.9-1.el7 将被 安装
--> 正在处理依赖关系 xrdp-selinux = 1:0.9.9-1.el7,它被软件包 1:xrdp-0.9.9-1.el7.x86_64 需要
--> 正在处理依赖关系 xorgxrdp,它被软件包 1:xrdp-0.9.9-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 xorgxrdp.x86_64.0.0.2.9-1.el7 将被 安装
---> 软件包 xrdp-selinux.x86_64.1.0.9.9-1.el7 将被 安装
--> 正在处理依赖关系 selinux-policy >= 3.13.1-229.el7_6.6,它被软件包 1:xrdp-selinux-0.9.9-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 selinux-policy.noarch.0.3.13.1-229.el7 将被 升级
--> 正在处理依赖关系 selinux-policy = 3.13.1-229.el7,它被软件包 selinux-policy-targeted-3.13.1-229.el7.noarch 需要
--> 正在处理依赖关系 selinux-policy = 3.13.1-229.el7,它被软件包 selinux-policy-targeted-3.13.1-229.el7.noarch 需要
---> 软件包 selinux-policy.noarch.0.3.13.1-229.el7_6.12 将被 更新
--> 正在检查事务
---> 软件包 selinux-policy-targeted.noarch.0.3.13.1-229.el7 将被 升级
---> 软件包 selinux-policy-targeted.noarch.0.3.13.1-229.el7_6.12 将被 更新
--> 解决依赖关系完成
依赖关系解决
=======================================================================================================================================================
Package 架构 版本 源 大小
=======================================================================================================================================================
正在安装:
xrdp x86_64 1:0.9.9-1.el7 epel 419 k
为依赖而安装:
xorgxrdp x86_64 0.2.9-1.el7 epel 63 k
xrdp-selinux x86_64 1:0.9.9-1.el7 epel 16 k
为依赖而更新:
selinux-policy noarch 3.13.1-229.el7_6.12 updates 484 k
selinux-policy-targeted noarch 3.13.1-229.el7_6.12 updates 6.9 M
事务概要
=======================================================================================================================================================
安装 1 软件包 (+2 依赖软件包)
升级 ( 2 依赖软件包)
总计:7.9 M
总下载量:499 k
Downloading packages:
警告:/var/cache/yum/x86_64/7/epel/packages/xrdp-selinux-0.9.9-1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY 0 B --:--:-- ETA
xrdp-selinux-0.9.9-1.el7.x86_64.rpm 的公钥尚未安装
(1/3): xrdp-selinux-0.9.9-1.el7.x86_64.rpm | 16 kB 00:00:00
(2/3): xorgxrdp-0.2.9-1.el7.x86_64.rpm | 63 kB 00:00:01
(3/3): xrdp-0.9.9-1.el7.x86_64.rpm | 419 kB 00:00:28
-------------------------------------------------------------------------------------------------------------------------------------------------------
总计 17 kB/s | 499 kB 00:00:28
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
导入 GPG key 0x352C64E5:
用户ID : "Fedora EPEL (7) "
指纹 : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
软件包 : epel-release-7-11.noarch (@extras)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新 : selinux-policy-3.13.1-229.el7_6.12.noarch 1/7
正在安装 : xorgxrdp-0.2.9-1.el7.x86_64 2/7
正在安装 : 1:xrdp-selinux-0.9.9-1.el7.x86_64 3/7
正在安装 : 1:xrdp-0.9.9-1.el7.x86_64 4/7
正在更新 : selinux-policy-targeted-3.13.1-229.el7_6.12.noarch 5/7
清理 : selinux-policy-targeted-3.13.1-229.el7.noarch 6/7
清理 : selinux-policy-3.13.1-229.el7.noarch 7/7
验证中 : xorgxrdp-0.2.9-1.el7.x86_64 1/7
验证中 : 1:xrdp-0.9.9-1.el7.x86_64 2/7
验证中 : selinux-policy-targeted-3.13.1-229.el7_6.12.noarch 3/7
验证中 : 1:xrdp-selinux-0.9.9-1.el7.x86_64 4/7
验证中 : selinux-policy-3.13.1-229.el7_6.12.noarch 5/7
验证中 : selinux-policy-3.13.1-229.el7.noarch 6/7
验证中 : selinux-policy-targeted-3.13.1-229.el7.noarch 7/7
已安装:
xrdp.x86_64 1:0.9.9-1.el7
作为依赖被安装:
xorgxrdp.x86_64 0:0.2.9-1.el7 xrdp-selinux.x86_64 1:0.9.9-1.el7
作为依赖被升级:
selinux-policy.noarch 0:3.13.1-229.el7_6.12 selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.12
完毕!
[root@localhost usr]# systemctl start xrdp
[root@localhost usr]# systemctl enable xrdp
Created symlink from /etc/systemd/system/multi-user.target.wants/xrdp.service to /usr/lib/systemd/system/xrdp.service.
[root@localhost usr]# systemctl status xrdp.service
● xrdp.service - xrdp daemon
Loaded: loaded (/usr/lib/systemd/system/xrdp.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2019-05-18 23:26:13 CST; 1min 35s ago
Docs: man:xrdp(8)
man:xrdp.ini(5)
Main PID: 17440 (xrdp)
CGroup: /system.slice/xrdp.service
└─17440 /usr/sbin/xrdp --nodaemon
5月 18 23:26:13 localhost.localdomain systemd[1]: Started xrdp daemon.
5月 18 23:26:13 localhost.localdomain xrdp[17440]: (17440)(140395270834624)[INFO ] starting xrdp with pid 17440
5月 18 23:26:13 localhost.localdomain xrdp[17440]: (17440)(140395270834624)[INFO ] listening to port 3389 on 0.0.0.0
[root@localhost usr]# systemctl status xrdp.service
● xrdp.service - xrdp daemon
Loaded: loaded (/usr/lib/systemd/system/xrdp.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2019-05-18 23:26:13 CST; 1min 50s ago
Docs: man:xrdp(8)
man:xrdp.ini(5)
Main PID: 17440 (xrdp)
CGroup: /system.slice/xrdp.service
└─17440 /usr/sbin/xrdp --nodaemon
5月 18 23:26:13 localhost.localdomain systemd[1]: Started xrdp daemon.
5月 18 23:26:13 localhost.localdomain xrdp[17440]: (17440)(140395270834624)[INFO ] starting xrdp with pid 17440
5月 18 23:26:13 localhost.localdomain xrdp[17440]: (17440)(140395270834624)[INFO ] listening to port 3389 on 0.0.0.0
[root@localhost usr]# ss -antup|grep xrdp
tcp LISTEN 0 2 127.0.0.1:3350 *:* users:(("xrdp-sesman",pid=17438,fd=7))
tcp LISTEN 0 2 *:3389 *:* users:(("xrdp",pid=17440,fd=11))
[root@localhost usr]# gdmflexiserver --xnest
** (gdmflexiserver:1038): WARNING **: 23:30:38.645: Not yet implemented
[root@localhost usr]# yum install tigervnc-server tigervnc-server-module
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.163.com
* updates: mirrors.163.com
gitlab_gitlab-ee/x86_64/signature | 836 B 00:00:00
gitlab_gitlab-ee/x86_64/signature | 1.0 kB 00:00:00 !!!
gitlab_gitlab-ee-source/signature | 836 B 00:00:00
gitlab_gitlab-ee-source/signature | 951 B 00:00:00 !!!
正在解决依赖关系
--> 正在检查事务
---> 软件包 tigervnc-server.x86_64.0.1.8.0-13.el7 将被 安装
---> 软件包 tigervnc-server-module.x86_64.0.1.8.0-13.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=======================================================================================================================================================
Package 架构 版本 源 大小
=======================================================================================================================================================
正在安装:
tigervnc-server x86_64 1.8.0-13.el7 base 215 k
tigervnc-server-module x86_64 1.8.0-13.el7 base 218 k
事务概要
=======================================================================================================================================================
安装 2 软件包
总下载量:432 k
安装大小:1.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): tigervnc-server-1.8.0-13.el7.x86_64.rpm | 215 kB 00:00:00
(2/2): tigervnc-server-module-1.8.0-13.el7.x86_64.rpm | 218 kB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------
总计 1.3 MB/s | 432 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : tigervnc-server-1.8.0-13.el7.x86_64 1/2
正在安装 : tigervnc-server-module-1.8.0-13.el7.x86_64 2/2
验证中 : tigervnc-server-module-1.8.0-13.el7.x86_64 1/2
验证中 : tigervnc-server-1.8.0-13.el7.x86_64 2/2
已安装:
tigervnc-server.x86_64 0:1.8.0-13.el7 tigervnc-server-module.x86_64 0:1.8.0-13.el7
完毕!
[root@localhost usr]# yum install vnc
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.163.com
* updates: mirrors.163.com
gitlab_gitlab-ee/x86_64/signature | 836 B 00:00:00
gitlab_gitlab-ee/x86_64/signature | 1.0 kB 00:00:00 !!!
gitlab_gitlab-ee-source/signature | 836 B 00:00:00
gitlab_gitlab-ee-source/signature | 951 B 00:00:00 !!!
正在解决依赖关系
--> 正在检查事务
---> 软件包 tigervnc.x86_64.0.1.8.0-13.el7 将被 安装
--> 正在处理依赖关系 tigervnc-icons,它被软件包 tigervnc-1.8.0-13.el7.x86_64 需要
--> 正在处理依赖关系 libfltk_images.so.1.3()(64bit),它被软件包 tigervnc-1.8.0-13.el7.x86_64 需要
--> 正在处理依赖关系 libfltk.so.1.3()(64bit),它被软件包 tigervnc-1.8.0-13.el7.x86_64 需要
--> 正在检查事务
---> 软件包 fltk.x86_64.0.1.3.4-1.el7 将被 安装
---> 软件包 tigervnc-icons.noarch.0.1.8.0-13.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=======================================================================================================================================================
Package 架构 版本 源 大小
=======================================================================================================================================================
正在安装:
tigervnc x86_64 1.8.0-13.el7 base 240 k
为依赖而安装:
fltk x86_64 1.3.4-1.el7 base 560 k
tigervnc-icons noarch 1.8.0-13.el7 base 38 k
事务概要
=======================================================================================================================================================
安装 1 软件包 (+2 依赖软件包)
总下载量:838 k
安装大小:2.1 M
Is this ok [y/d/N]: y
Is this ok [y/d/N]: y
Downloading packages:
(1/3): tigervnc-1.8.0-13.el7.x86_64.rpm | 240 kB 00:00:00
(2/3): tigervnc-icons-1.8.0-13.el7.noarch.rpm | 38 kB 00:00:00
(3/3): fltk-1.3.4-1.el7.x86_64.rpm | 560 kB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------
总计 2.1 MB/s | 838 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : fltk-1.3.4-1.el7.x86_64 1/3
正在安装 : tigervnc-icons-1.8.0-13.el7.noarch 2/3
正在安装 : tigervnc-1.8.0-13.el7.x86_64 3/3
验证中 : tigervnc-1.8.0-13.el7.x86_64 1/3
验证中 : tigervnc-icons-1.8.0-13.el7.noarch 2/3
验证中 : fltk-1.3.4-1.el7.x86_64 3/3
已安装:
tigervnc.x86_64 0:1.8.0-13.el7
作为依赖被安装:
fltk.x86_64 0:1.3.4-1.el7 tigervnc-icons.noarch 0:1.8.0-13.el7
完毕!
[root@localhost usr]# rpm -q tigervnc tigervnc-server
tigervnc-1.8.0-13.el7.x86_64
tigervnc-server-1.8.0-13.el7.x86_64
[root@localhost usr]# yum install tigervnc-server -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* epel: mirrors.njupt.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
软件包 tigervnc-server-1.8.0-13.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost usr]# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
[root@localhost usr]# vim /etc/systemd/system/vncserver@:1.service
[root@localhost usr]# systemctl start vncserver@:1.service
Job for vncserver@:1.service failed because the control process exited with error code. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
[root@localhost usr]# systemctl enable vncserver@:1.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vncserver@:1.service to /etc/systemd/system/vncserver@:1.service.
[root@localhost usr]# systemctl enable vncserver@:1.service
[root@localhost usr]# vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? y
Password:
Verify:
xauth: file /root/.Xauthority does not exist
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
[root@localhost usr]# vi /etc/ssh/sshd_config
[root@localhost usr]# firewall-cmd --permanent --add-service vnc-server
success
[root@localhost usr]# firewall-cmd --zone=public --add-port=5901/tcp --permanent
success
[root@localhost usr]# firewall-cmd --reload
success
[root@localhost usr]# systemctl status vncserver@:1
● vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 日 2019-05-19 00:15:06 CST; 15min ago
5月 19 00:15:06 localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)...
5月 19 00:15:06 localhost.localdomain runuser[31853]: runuser: user rootvnc does not exist
5月 19 00:15:06 localhost.localdomain systemd[1]: vncserver@:1.service: control process exited, code=exited status=1
5月 19 00:15:06 localhost.localdomain systemd[1]: Failed to start Remote desktop service (VNC).
5月 19 00:15:06 localhost.localdomain systemd[1]: Unit vncserver@:1.service entered failed state.
5月 19 00:15:06 localhost.localdomain systemd[1]: vncserver@:1.service failed.
[root@localhost usr]# vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:1 4075
[root@localhost usr]# ps aux |grep vnc
root 4075 0.0 0.5 252680 45424 pts/0 Sl 00:16 0:00 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop localhost.localdomain:1 (root) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -pn -rfbauth /root/.vnc/passwd -rfbport 5901 -rfbwait 30000
root 4239 0.0 0.0 113176 1208 pts/0 S 00:16 0:00 /bin/sh /root/.vnc/xstartup
root 14594 0.0 0.0 112728 988 pts/0 S+ 00:30 0:00 grep --color=auto vnc