In the example of wanting to access a computer in your home, you can implement this fairly easily using entirely free software with VNC-over-SSH, but it's depending on having a public IP address and open port on your home NAT/router.
One of the main reasons that things like gotomypc and teamviewer have been successful in the market is the huge number of people who don't know how to/don't care to take the time to set up an SSH tunneled setup, and want something to "just work" through NAT.
My setup looks something like this, with public/private key SSH auth. Copied and pasted from my notes, hostnames and IP addresses redacted:
-------
I have a static /30 and forward port 445 on the external side of my home router, through the NAT to port 22 on the workstation PC in my rfc1918 IP space.
workstationhostname.domainname.org normally has vnc session listening on port 5901 localhost only, spawned with:
vnc4server -geometry 1920x1200 -localhost
This is for use with an SSH tunnel coming from hostname.ofmy.static.slash30.org:445 through NAT to workstationname.rfc1918.ip.address port 22
To access from the outside world, on the client, do the following:
ssh -v -L 5901:localhost:5901 -N -f -l myusername -p 445 hostname.ofmy.static.slash30.org
use client system's vnc client software to connect to 127.0.0.1:5901
To access from inside the LAN, on the client, do the following:
ssh -v -L 5901:localhost:5901 -N -f -l myusername -p 22 workstationname.rfc1918.ip.address
use client system's vnc client software to connect to 127.0.0.1:5901