Skip to content

Setting Up and Troubleshooting VNC Connections

Jacqueline Ryan edited this page Jul 6, 2020 · 4 revisions

Set Up

Download VNC Viewer here: https://www.realvnc.com/en/connect/download/viewer/ If the VNC Server hasn't been setup already, it needs to be setup on the desktop you are trying to connect to. Download VNC Server here: https://www.realvnc.com/en/connect/download/vnc/ . The setup of the VNC Server includes setting a username and password to be used when connecting using the VNC Viewer. Once the VNC Server and VNC Viewer are downloaded and set up you will be able to connect to the remote desktop on VNC Server.

Note: This connection might be unsecure. If you want a secure connection look at the For a Secure Connection section. When the VNC Viewer is opened there will be a window with a place to enter in the IP Address. Here you will enter your IP Address. Before connecting be sure to connect to the VPN. If you enter only the IP Address and it doesn't connect then try to enter the IP Address with a remote port such as IP_ADDRESS:1, IP_ADDRESS:5901, or IP_ADDRESS::5901. When prompted enter the password for the remote desktop you are trying to connect to.

For a Secure Connection

Connecting to the remote desktop without tunneling is not as secure since it is not encrypted. Remotely connecting over SSH with tunneling is more secure.

Connecting to the Remote Desktop via Real VNC Viewer from Above

Before connecting be sure to connect to the VPN. First go into your terminal and enter in the command below with your remote desktop information. The user is the remote desktop's username, the machine.somewhere is the remote desktop's IP Address, and the port is whichever port you want to SSH tunnel through to the remote desktop.

$ ssh user@machine.somehwere -L port:localhost:port

Example:

$ ssh rduce@IP_ADDRESS -L 5901:localhost:5901

You will then be prompted to enter in the password for the remote desktop. After connecting head over to the VNC Viewer and enter this as the VNC Server address: localhost:Port. Example: localhost:5901. A window will open up and you should now be connected to the Linux machine via VNC.

Connecting to the Remote Desktop via Mac Built-in VNC Viewer

Before connecting be sure to connect to the VPN. First go into your terminal and enter in the command below with your remote desktop information. The user is the remote desktop's username, the machine.somewhere is the remote desktop's IP Address, and the port is whichever port you want to SSH tunnel through to the remote desktop.

$ ssh user@machine.somehwere -L port:localhost:port

Example:

$ ssh rduce@IP_ADDRESS -L 5901:localhost:5901

You will then be prompted to enter in the password for the remote desktop. To connect to the VNC session we setup, follow these steps. First, click on the "Go" menu and choose connect to server.

MacOS has a VNC Viewer already built into it. For the Server Address, type vnc://localhost:5901 where 5901 was the port we forwarded above.

If you set up a password for your VNC session, it will then prompt you to enter it.

A window will open up and you should now be connected to the Linux machine via VNC.

Editing the VNC xstartup File

First go into your xstartup file. This is the standard location of the VNC xstartup file on Linux:

$ vim .vnc/xstartup

The contents of the VNC xstartup file should be exactly like this:

#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
#unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export XKB_DEFAULT_RULES=base
export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb
startxfce4 &
#MODE=""
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
#startxfce4 &
#gnome-panel &
#gnome-settings-daemon &
#metacity &
#nautilus &
#gnome-session &

Troubleshooting

If you try to connect and a window with a grey screen with an X cursor shows up then try to connect to a different remote port. If that doesn't work then check that your VNC xstartup file is exactly like the one shown above.