xRDP protocol is a bit slow to connect based on my previous testing. This time, I am trying to use VNC protocol to do connection, which has been proven much faster than xRDP.
My previous post “Connect to GNOME desktop environment via xRDP on CentOS 7 & Ubuntu 18” shows how to use RDP client connecting to linux but connection speed is too slow for regular operation. Compared both, VNC solution is much better for daily operation remote control experience when using it on Linux server.
Pre-requirements
1 Update CentOS
yum update -y
2 Enable Password Authentication (Not Secure)
$ sudo passwd netsec
$ vi etc/ssh/sshd_config
PasswordAuthentication yes
3 Increase Swap partition file size
https://blog.51sec.org/2020/03/change-swap-size-to-improve-low-memory.html
[root@centos7-zabbix-client ~]# sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
1048576+0 records in
1048576+0 records out
1073741824 bytes (1.1 GB) copied, 27.5052 s, 39.0 MB/s
[root@centos7-zabbix-client ~]# sudo chmod 600 /swapfile
[root@centos7-zabbix-client ~]# sudo mkswap /swapfile
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=d126e13f-162d-4a1d-998c-f8e4152e4f8b
[root@centos7-zabbix-client ~]# sudo swapon /swapfile
[root@centos7-zabbix-client ~]# vi /etc/fstab
Add a new line into /etc/fstab file:
/swapfile swap swap defaults 0 0
4 Create a new VNC user
useradd -m -s /bin/bash john
passwd john
sudo su
Install xfce and vnc server
Initial VNC Configuration
su – john
mv ~/.vnc/xstartup ~/.vnc/xstartup.bekup
vi ~/.vnc/xstartup
#!/bin/bash xrdb $HOME/.Xresources startxfce4 &
vncserver
vncserver
vncserver -list
Running TigerVNC as a Service
cp
command:sudo cp /usr/lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
sudo vi /etc/systemd/system/vncserver@\:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=john
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver %I
PIDFile=/home/john/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable vncserver@:1.service
1
after the @
sign defines the display port on which the VNC service will run. In this example, that is the default 1
, and the VNC server will listen on port 5901
.sudo systemctl start vncserver@:1.service
sudo systemctl status vncserver@:1.service
Configure VNCViewer to Connect to Server