1. Install VNC Server
- X11 VNC
- TigerVNC
Server$ sudo apt-get install tigervnc-standalone-server
Server$ vncpasswd
#Passwd:
#Verity:
#Would you like to enter a view-only password (y/n)? n
vi ~/.vnc/xstartup
vi ~/.vnc/configfor gnome
# ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
gnome-sessionfor xfce4
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/usr/bin/startxfce4
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
x-window-manager &
config
# ~/.vnc/config
geometry=1920x1080
# geometry=3840x2160
# geometry=1440x900
dpi=96Server$ chmod u+x ~/.vnc/xstartup2. Start VNC Servr
Server$ vncserver
New Xtigervnc server 'Server:2 (server)' on port 5901 for display :1.
Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/username/.vnc/passwd :1 to connect to the VNC server.display β:1β is VNC display number 5900 + display number is VNC sever port.
3. VNC port Tunneling
# tunneling and connect ssh server
localhost$ ssh -L vnc_client_port:localhost:vnc_server_port user_name@name_of_server
ex) localhost$ ssh -L 12345:localhost:5901 server_user@IP_or_domain -p sshport(22)
# setting display
Server$ export DISPLAY=:display_number
ex) Server$ export DISPLAY=:1
# check VNC status
Server$ vncserver --list
X DISPLAY RFB PORT RFB UNIX PATH PROCESS ID SERVER
1 5901 12994 Xtigervnc4. VNC viewer
install VNC viewer and connect While VNC port tunneling, localhost:vnc_client_port ex) localhost:12345
5. VNC close
Server$ vncserver -kill :display_number
ex) Server$ vncserver -kill :1
# stop ssh tunneling
Server$ exit