yum update
安装GNOME Desktop图形桌面服务
yum groupinstall "GNOME Desktop"
Or KDE:
yum groupinstall "KDE"
安装vnc
yum install tigervnc-server
查看系统运行模式
systemctl get-default
切换到桌面运行模式
systemctl set-default graphical.target
启动桌面模式
init 5
设置桌面运行模式为默认启动模式
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
设置vnc用systemctl来管理(第一个用户vncserver@:1.service,第二个用户vncserver@:2.service,其他以此类推)
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
vi /etc/systemd/system/vncserver@: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 :1 > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver -localhost no :1 -securitytypes=none -fp /usr/share/X11/fonts/misc"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/usr/bin/vncserver-kill :1
[Install]
WantedBy=multi-user.target
systemctl enable vncserver@1.service
systemctl start vncserver@1.service
iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
测试:
vncserver :1
修改密码:
vncserver -kill :1
rm ~/.vnc/passwd
下载VNC viewer
https://github.com/TigerVNC/tigervnc/releases
Windows
在windows上安装vnc客户端,然后输入xxx.xxx.xxx.xxx:1,连接登录