centos8 VNC-server设置
1、安装VNC-server
dnf -y install tigervnc-server tigervnc-server-module
rpm -qa |grep vnc
2、设置vnc密码
#在需要用vnc远程的用户下执行该命令
vncpasswd
3、修改vnc配置文件
vim /etc/system/systemd/vncserver@:1.service
添加以下内容
[Unit]
Description=Remote Desktop VNC Service
After=syslog.target network.target
[Service]
Type=forking
Working
Directory=/home/pkumar
User=pkumar
Group=pkumar
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=
/usr/sbin/runuser -l root -c "/usr/bin/vncserver -autokill %i"
ExecStop=/usr/bin/vncserver -kill %i
PIDFile=/root/.vnc/%H%i.pid
[Install]
WantedBy=multi-user.target
4、启动vncserver
systemctl daemon-reload
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service
5、验证vncserrver
ss -tunlp |grep 5901
vnc在linux默认端口为5900+n,n为打开的第几个vnc进程。
6、用vnc-view验证
需要关闭selinux和firewall
参考 https://www.linuxidc.com/Linux/2019-07/159415.htm