assuming you have ssh access to the remote machine, you can open up a vnc pipeline to it by tunneling vnc traffic (port 5900) over ssh.
here's a guide to setting up the tunnel.
http://www.mactech.com/articles/mactech/Vol.20/20.07/VNCOverSSH/index.html
then once you've created the tunnel, at the command line prompt in terminal, just type
$ vnc 127.0.0.1
"vnc" will launch "screen sharing" app, and the address 127.0.0.1 (port 5900 only) is now being piped over your ssh tunnel to the other machine.
This is a neat way to leave the vnc (screen sharing) ports closed on your firewall for added security, yet still be able to screen share with the remote computer as needed.
The key thing here is that the screen sharing port (5900) is closed at the fire wall, but you have left the screen sharing feature turned on in the services menu of system preferenced.