User Tools

Site Tools


atmos:citation:soft:vnc

THIS PAGE IS OUTDATED, NEEDS TO BE UPDATED. CONTACT DELENE FOR NEW VNC INFORMATION (As of 4/28/2023)

VNC Virtual Network Computing

These directions are for remotely connecting to a Linux computer using a VNC server.

Must have a good internet connection in order for it to not be extremely slow, but note that the school's VPN may be the issue if connection is really slow.

We will be using the RealVNC program, which includes the VNC Viewer and the VNC Server.

Creating a VNC file on Remote Linux Computer

  1. You must first create a vnc file on the computer you are wishing to gain external access to (the server computer).
  2. Make sure you add this file to /home/<username>/.vnc/
  3. To make the new file (an xstartup file), paste the sample code below into a text file.
  4. After you have created the startup file, go to a terminal window and type vncpasswd, next enter the password you would like to use when accessing the server computer. (This will only be your VNC password when you are starting VNC)
  5. In a terminal window type in vncserver to start the server. More information and functions about starting and killing the server in the Extra Information section of this page.
  6. Make sure this file is executable. If not, make executable by typing chmod +x xstartup in terminal window

xstartup code for RedHat Linux Computers (for example aircraft.atmos.und.ued)

See /nas/setup/xstartup-aircraft. Put the below “code” in .vnc/xstartup using editor or cp. For example, cp /nas/setup/xstartup-aircraft ~/.vnc/xstartup

#!/bin/sh

vncconfig -iconic &

#Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey 
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &
#IF YOUR NOT ABLE TO OPEN A GNOME TERMINAL IN YOUR VNC SESSION, COMMENT OUT THE LINE ABOVE AND UNCOMMENT OUT THE LINE BELOW!
#exec gnome-session &
0

xstartup code for Linux Mint Computers (for example Clifford Hall 422 computers)

#!/bin/sh


# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
# exec /etc/X11/xinit/xinitrc

[ -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" &
mate-session &

xstartup code for Ubuntu (for example Calgary)

#!/bin/sh

#Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey 
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
mate-session &

Starting and Killing the Remote Linux VNC Server

  • To Start Server:
    • Type into a terminal window (on the server computer): vncserver
    • You can also choose the display number by using this command: vncserver :* (where * is the display number, make sure you watch your spacing!)
    • This will keep the server running until the computer is restarted or the power fails. This is also the reason why the computers in the computer labs are left on.
    • Next, go back onto your local machine, and create the directory
      mkdir /home/<user.name>/bin
    • Now, create a new text file in vim (for example)
      vi vncaircraft
    • In that text file you need to insert “ps -ef | grep -i Xvnc”
#!/bin/bash
# Shell Access Aircraft using vnc client
export VNC_VIA_CMD='/usr/bin/ssh -2 -c aes128-cbc -x -p 22 -f -L %L:%H:%R %G sleep 2'
/usr/bin/vncviewer -FullColor -passwd ~/.vnc/passwd -via aircraft.atmos.und.edu :1
  • Note: You will need to manipulate part of this text file to match the server you're trying to connect to.
  • Note: you may need to change the server session number in the the created txt file to the server number you activated in the remote server: 'aircraft.atmos.und.edu :*' … * = the server number.
  • You also need to make this new text file that you created executable
    chmod +x vncaircraft
  • Next (still on your local machine), you need to create the same password as you did on the remote server.
    vncpasswd

    If it asks you if you would like to enter a view-only password say yes.

  • Finally, on your local machine go back to the
    /home/<user.name>/bin

    directory and run vncaircraft

    ./vncaircraft
  • To View Display Number
    • List the contents of the ~/.vnc directory on the remote computer (where the VNC server is running)
    • The display number of the currently running VNC server will be after the colon:
ls ~/.vnc/*.pid
computer_name:1.pid
  • To Terminate Server:
    • Type into a terminal window (on the server computer): vncserver -kill :* (where * is the number of the display)
  • To View All Running VNC Sessions
    • List all currently running sessions of VNC by username.
    • Please make sure you have only 1 instance of VNC running at a time!
ps -ef | grep -i Xvnc

VNC into Calgary

Do the same steps as above, however in your 'vnccalagary' file on your home server, you must input the following. NOTE: You may need to change some of the contents in this file such as your <user.name> and what server number.

#!/bin/bash
# Shell Access Aircraft using vnc client
export VNC_VIA_CMD='/usr/bin/ssh -2 -x -p 22 -f -L %L:%H:%R %G sleep 2'
/usr/bin/vncviewer -FullColor -passwd /home/<user.name>/.vnc/passwd -via <user.name>@134.129.222.140 :1

Also, you need to use the xstartup code file for Calgary which is displayed underneath the xstartup code for linux mint machines.

VNC into Aircraft

The major difference with the Aircraft server vnc usage is that people need to get someone with sudo access to start the vnc server for their port. That process consists of:

  1. Editing /etc/tigervnc/vncserver.users and add a line with vnc terminal number and username to the already existing list. (eg. :4=david.delene)
  2. Starting the server with, 'sudo systemctl enabe vncserver@\:n.service –now' where n is the number of the terminal.

Accessing the VNC server using Windows Operating System

Downloading RealVNC VNC Viewer

  1. Select your OS and click Download VNC Viewer
  2. Install as you would normally per your OS

Setting Up VNC Viewer on Windows (Putty)

1) Connect to the campus' VPN

2) Use PuTTY or the like to connect to the computer you want to remotely access

3) Start the VNC server as described in the Starting and Killing the Remote Linux VNC Server section and take note of the display number you are assigned

  • Example: After starting VNC server, you should get output something like this:
  New 'computer_name.atmos.und.edu:1 (username)' desktop is computer_name.atmos.und.edu:1
  • The :1 is the display number you have been assigned to run the VNC server on

4) Exit out of PuTTY while keeping the previous terminal open, reopen PuTTY, and type the following:

  • In the Sessions tab and in the Host Name or IP address tab, retype the computer you were just connected to
  • Navigate to the SSH > Tunnels tab and type in the Source port box: 59?? where ?? is the display number assigned to you. For example 09 or 16.
    • Note that display numbers beyond the single digits will change the form to 59?? , where ?? is for example 09 or 16.
  • In the same tab, type into the Destination box: localhost:59?? where ?? is the display number assigned to you.
    • Note that display numbers beyond the single digits will change the form to localhost:59??.
  • Click Add (next to the Source port box) and click the Open button on the bottom of the window
  • Remember to save your settings for easy future use. To save, go under “Session” and put in a Host Name (for example “localhost” and a Saved Sessions name (for example “Local”). Select Save. Next time, selection the session name (for example “Local”) and Load.
  • Type in your password to finish connecting to the remote Linux machine

5) Open VNC Viewer and type into the VNC Server box: localhost:?? where ?? is the display number assigned to you

  • Click the Connect button on the bottom of the window and enjoy!

Accessing the VNC server using Linux Terminal

You can access vnc through a Linux (i.e. Redhat) terminal window with the following command:

vncviewer -via <IP address> :<display number>

With the case of esxfedoralo, it would be the following command:

vncviewer -via 134.129.214.58 :<display number>

Other things you will need

  • You will need the school's VPN (Virtual Private Network) to get past the firewall
  • You will also need PuTTY SSH
  • Make sure to read the Wiki pages for both of these before continuing with this page

Extra Information for those interested

Terms and Definitions

  • VNC : Virtual Network Computing
    • “It is remote control software which allows you to view and fully interact with one computer desktop (the “VNC server”) using a simple program (the “VNC viewer”) on another computer desktop anywhere on the Internet.” (from www.realvnc.com, [http://www.realvnc.com/vnc/])
  • PuTTY SSH : PuTTY
    • SSH stands for Secure Shell and this program offers a secure channel between two networks (from Wikipedia.com [http://en.wikipedia.org/wiki/Secure_Shell])
    • This program, when using it with tunnelling, offers a secure channel by encrypting all information that passes through the channel.
  • Client : Your computer, or the computer that is trying to gain access to the server

Accessing the VNC server on OS X

OS X has a built in VNC viewer, so no extra software is needed to access the VNC server.

To access the VNC server: — David Delene 2020/10/19 23:12

  • Open Terminal and execute the following command to set up a port tunnel: ssh -L 59??:localhost:59?? -l <login name> <host name or IP address>. The host name for example is aircraft.atmos.und.edu. This creates an tunnel via ssh.
  • Open Finder and choose Go→Connect to Server
  • In the dialog box, enter vnc:/ /<hostname>:59?? where <hostname> is computer hostname or ip address. Use localhost if doing a tunnel via ssh (setup one). For the ?? in 59??, replace with display number. For example 07 or 14 for display 7 and 14.
  • Choose “Connect.
  • A window will prompt for your password. Enter it and you're all set!

To change the VNC viewer resolution:

  • Connect to the VNC server
  • Open settings within the linux operating system and choose Displays→Resolution→1920×1080

List of VNC Display Numbers Used by People

To allow scripting to access VNC, people may want to use the same display number, Hence, below is list, please add your name and number. Please use vncserver :? where ? is your display number.

  • Display Number - Name
  • 1 - Default 1 (Reserved - Don't Use if Possible)
  • 2 - Default 2 (Reserved - Don't Use if Possible)
  • 3 - Default 3 (Reserved - Don't Use if Possible)
  • 4 - David Delene*
  • 5 - Conrad Slad*
  • 6 - Derek Stinchfield
  • 7 - Kendra Sand*
  • 8 - Christian Nairy*
  • 9 - Andy Detwiler
  • 10 - Michael Willette*
  • 11 - Nicholas Camp
  • 12 - James Klinman*
  • 14 - Kathryn Bouslough*
  • 15 - Andrea Neumann*
  • 16 - Lucas Castro
  • 17 - Maddi (Madeline) Cruff
  • 18 - Andrew Fitzgerald
  • 19 - Joseph O'Brien
  • 20 - Shawn Wagner
  • 21 - Nick (Nicholas) Gapp
  • 24 - Jennifer Moore*
  • 25 - Andrew Delafrance
  • 26 - Peter
  • 27 - Saurabh Patil

* Active Users

To see how is using VNC Server session use the command “ps -ef | grep -i Xvnc”. To kill a session use vncserver -kill :? where ? is your display number.

atmos/citation/soft/vnc.txt · Last modified: 2024/01/11 19:27 by conslad