CentOS7安装远程桌面软件VNC Server
如果服务器为centos7_minimal版本,则需要安装desktop(服务器系统为centos7_desktop则忽略)
yum groupinstall -y "GNOME Desktop"
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
[[email protected] ~]# firewall-cmd --statenot running #查看防火墙是否关闭
not running
1.安装vnc server
yum install -y tigervnc-server tigervnc-server-module
2.复制vnc server的配置文件
[email protected]:1.service、[email protected]:2.service为连接不同的远程桌面,连接ip为ip:1、ip:2
(即为提供2个远程连接方式,VNC Server:ip:1、ip:2)
cp /lib/systemd/system/[email protected] /lib/systemd/system/[email protected]:1.service
cp /lib/systemd/system/[email protected] /lib/systemd/system/[email protected]:2.service
3.修改[email protected]:1.service、[email protected]:2.service配置文件
[[email protected] ~]# vi /lib/systemd/system/[email protected]:1.service
...
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
#ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
#use root to login --GUY_GO
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
#use root to login --GUY_GO
#PIDFile=/home/<USER>/.vnc/%H%i.pid
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
4.重新加载启动配置
systemctl daemon-reload
5.设置vnc server密码
[[email protected] ~]# vncpasswd
Password:
Verify:
Passwords don't match - try again
Password:
[[email protected] ~]# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
6.启动vnc server
[[email protected] ~]# vncserver #启动第一个远程桌面
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
[[email protected] ~]# vncserver #启动第二个远程桌面
New 'localhost.localdomain:2 (root)' desktop is localhost.localdomain:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:2.log
[[email protected] ~]#
或使用以下命令启动
systemctl start [email protected]:1.service
systemctl start [email protected]:2.service
7.关闭vncserver
pkill -9 vnc 或 systemctl stop [email protected]:1.service
8.使用VNC Viewer连接
windows下载vnc viewer并安装;