Tag Archives: VNC

Tunnel Connections with SSH

SSH is one of my favorite networking tools as it is straight forward to use, comes pre-installed on OSX and most Linux distros and provides a great way of securely accessing network services from remote locations.

Because my home server doesn’t have a static IP address I have been using the free service by no-ip.org which updates it’s DNS records when your IP address changes. I then set up my router to forward port 222 (ssh is normally 22 but setting a non standard port means you don’t get as many bots trying to guess your login details) to port 22 of my server on my home LAN.

Once you have setup ssh and have forwarded port 22 from your router to your ssh server you can use the command below in terminal to forward connections:

 ssh -L 5901: username@servername.no-ip.org -p 222 -N 

-L sets up local forwarding

5901 is the local port you will connect to that will be forwarded to the remote system is the remote system that the port will be forward to. is the localhost, or system running the ssh server, but you can use another system on your network such as if you want.

5900 is the remote port that the connection will be forwarded to (5900 is VNC in this case)

username@servername.no-ip.org is your username followed by Internet address of your server

-p 222 specifies a non standard SSH port

-N means that only the tunnel will be created not a remote shell.

In OSX you can then press Command-K in finder and type vnc:// to view the screen of the remote computer with all traffic between you local and remote system encrypted via ssh.

I recommended using a private public key and not passwords when settings this up for even more security.

VNC Connect Applescript

At the studio we run a Mac based network with multiple servers and clients. With remote desktop enabled on the Macs or a VNC server (such as Tight VNC) on Windows it’s easy to view and control the screens of remote systems. Which is pretty handy when most of your systems are located in a distant machine room and don’t want to get off your chair.
While it’s pretty easy to select the computer in the finder and press screen share, I decided to write an Applescript to streamline the process of frequently connecting to same remote systems and thought I would share it in case anyone finds it useful.

The remote systems will need to have a static IP address and this script will only work with OSX 10.5 and up.
To customise the script all you need to do is change the values in the lists and ensure that the name and address values keep their relative position in the list. You can also add more than three systems by just adding to lists.


(* VNC Connect script v1 www.sandymilne.com *)

on get_pos(aCompterName, aList)
	repeat with theItem from 1 to the count of aList
		if item theItem of aList is aCompterName then return theItem
	end repeat
	return 0
end get_pos

(* Set computer address and Names *)

set computerNameList to {"Server", "Windoze", "iMac 1"}
set computerAddressList to {"", "", ""}

set selectedHostName to choose from list computerNameList with prompt "Select a host:"

if selectedHostName is not equal to false then
	set connectwith to item (get_pos((selectedHostName as string), computerNameList)) of the computerAddressList
	do shell script "open -W vnc://" & connectwith
end if


You can download the script here:
VNC Connect.zip