Install the vncserver
$ sudo apt update; sudo apt install tigervnc-standalone-server tigervnc-xorg-extension -y
Setup a password for vncserver
$ vncpasswd
Once you have provided the password, make sure a passwd file is created
$ ls ~/.vnc/
passwd
Run below command to put some settings in ~/.vnc/xstartup, so that gnome will be started when vnc is used
$ cat > ~/.vnc/xstartup <<EOF
#!/bin/sh
# Start Gnome 3 Desktop
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session gnome-session &
EOF
Press ctrl-d to save the above file
Start a vncserver instance
$ vncserver
List the display to get the port number to connect to, in this example the port number would be 5901, since the display number is 1
$ vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:1 5375
In the client machine, connect with using vncviewer like below, replacing the x.x.x.x with your server's ip number
$ vncviewer x.x.x.x:5901
To terminate the vnc session, use below command to kill the first instance of the vncserver
$ vncserver -kill :1
No comments:
Post a Comment