How to Setup TigerVNC on Jetson Nano

After spending time getting the native Vino VNC server running, I could not believe how crappy the screen response time was. Mouse clicks took forever, let alone the lag from trying to type something into the Terminal or Microsoft Code without misspelling it. This felt wrong; VNC is usually very responsive, especially inside a local network. This aggravation led me to to comb through blog and forum posts searching for a complete walkthru on how to set up TigerVNC. I could not find one, so I created one.

Standing on the shoulders of others, I present this end-to-end guide to you. Its the synthesis of other posts into one complete document that you can follow to get TigerVNC working and have a VERY responsive, smooth VNC server at the end to get real work done.

I did most of this work via SSH command line, but it may be helpful for you to do this at the console of the Nano itself. Your choice. Note that after you complete this, you do not need to have an HDMI cable plugged into the Nano; I only have power, Ethernet, and a webcam plugged in, and both VNC and SSH work perfectly. I have found VNC Connect from RealVNC to be a great VNC client for the Mac (and other platforms).

A few system housekeeping updates before we get started to ensure everything is up-to-date. I also install Nano here for text editing:
sudo apt-get update sudo apt-get upgrade
$ sudo apt-get install nano

Install Tiger VNC itself:
$ sudo apt install tigervnc-standalone-server

Set a password for VNC. You don’t need a view-only password.
vncpasswd

Change to the ~/.vnc directory and create your xstartup file:
cd ~/.vnc sudo nano xstartup

Add the following contents to your xstartup file where is your home directory name:
!/bin/sh
export XDG_RUNTIME_DIR=/run/user/1000
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
xrdb /home//.Xresources
xsetroot -solid grey
gnome-session &
startlxde &

Make the xstartup file executable:
$ sudo chmod 755 ~/.vnc/xstartup

Check to see if the .Xresources file is present where is your home directory:
$ ls -al /home//.Xresources

Create the .Xresources file if it does not already exist
$touch /home//.Xresources

Set VNC to start automatically. Change to the correct systemd directory:
cd /etc/systemd/system Create a file called vncserver@.service (yes, that @ symbol is required) sudo nano vncserver@.service

Add the text below into the file, changing the user, group, and home directory to reflect your installation. Change the monitor resolution in the ExecStart line to your preferred resolution (mine is 2560Γ—1400, but I also included a sample for 1080P resolution that is commented out for your convenience).

[Unit]
Description=Start TigerVNC Server at startup
After=syslog.target network.target

[Service]
Type=forking
User=
Group=
WorkingDirectory=/home/<home_directory>
PIDFile=/home//.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :%i -depth 24 -geometry 1920Γ—1080 -nolisten tcp

ExecStart=/usr/bin/vncserver :%i -depth 24 -geometry 2560Γ—1400 -nolisten tcp

ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

Check the /etc/vnc.conf and ensure VNC server access is enabled from more than just localhost:
$ sudo nano /etc/vnc.conf

Inside the vnc.conf file, ensure that the following line is uncommented:
$localhost = β€œno”;

Configure auto-login with GDM3 (if not already configured you created your Nano installation:
$ sudo nano /etc/gdm3/custom.conf

In the custom.conf file, uncomment or add the following lines:
AutomaticLoginEnable=true
AutomaticLogin=

Add vnc to start at reboot by running the following two commands. One restarts the daemons, and the other creates a symlink to the vncserver@.service you created earlier.

sudo systemctl daemon-reload sudo systemctl enable vncserver@1
Created symlink /etc/systemd/system/multi-user.target.wants/vncserver@1.service β†’ /etc/systemd/system/vncserver@.service.

Test that the VNC service starts and review its status before rebooting
sudo systemctl start vncserver@1 sudo systemctl enable vncserver@1

Check for any errors that show up here.

Reboot the Nano. You should now be able to connect via a VNC client to the Nano by using a connection string that looks like this: 192.168.0.101:1

Here my Nano has the IP address 192.168.0.101 and its connecting to the :1 instance of VNC. If you are unable to connect, login to the Nano via SSH and begin troubleshooting:

Check to see that the VNC process is actually running:
$ ps -ax |grep vnc
5590 ? Sl 0:20 /usr/bin/Xtigervnc :1 -desktop nvidia-desktop:1 (cosjef) -auth /home/cosjef/.Xauthority -geometry 1920Γ—1080 -depth 24 -rfbwait 30000 -rfbauth /home/cosjef/.vnc/passwd -rfbport 5901 -pn -SecurityTypes VncAuth,TLSVnc -nolisten tcp
13789 pts/3 S+ 0:00 grep –color=auto vnc

Check to see if the VNC server is listening on ALL ports, as designated by the 0.0.0.0 IP address with port 5901 active. It should look something like this:
$ netstat -pantl | grep LISTEN
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 5590/Xtigervnc
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN –
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:38043 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:2947 0.0.0.0:* LISTEN –
tcp6 0 0 :::5901 :::* LISTEN 5590/Xtigervnc
tcp6 0 0 :::111 :::* LISTEN –
tcp6 0 0 ::1:53 :::* LISTEN –
tcp6 0 0 :::22 :::* LISTEN –
tcp6 0 0 ::1:2947 :::* LISTEN –

Check the actual log files that TigerVNC writes for any specific errors. A success operation will look something like the logfile below:
$ cat ~/.vnc/nvidia-desktop:1.log
Sat Apr 3 20:32:32 2021
Connections: accepted: 192.168.0.100::63695
SConnection: Client needs protocol version 3.8
SConnection: Client requests security type VncAuth(2)
VNCSConnST: Server default pixel format depth 24 (32bpp) little-endian rgb888
VNCSConnST: Client pixel format depth 6 (8bpp) rgb222
VNCSConnST: Client pixel format depth 24 (32bpp) little-endian rgb888

Sat Apr 3 20:32:34 2021
Connections: closed: 192.168.0.100::63695 (Clean disconnection)
EncodeManager: Framebuffer updates: 3
EncodeManager: ZRLE:
EncodeManager: Indexed RLE: 34 rects, 2.07486 Mpixels
EncodeManager: 82.4463 KiB (1:24.6181 ratio)
EncodeManager: Full Colour: 34 rects, 2.07403 Mpixels
EncodeManager: 2.07756 MiB (1:3.8084 ratio)
EncodeManager: Total: 68 rects, 4.14889 Mpixels
EncodeManager: 2.15808 MiB (1:4.58478 ratio)

1 Like

Great! Thanks for your sharing to community!

Thanks for your sharing, it’s really helpful to me!

1 Like