How to Setup VNC Between a Mac and Ubuntu
This tutorial instructs you how to quickly VNC into a headless Ubuntu server. It’s assumed that you have a server running somewhere and for whatever reason you need access to a graphical environment or browser instead of just SSH. Of course, all of the normal security precautions apply here. Tested on Ubuntu 12.04.1 server (64-bit).
On the Server
SSH into the server and run the following:
$ sudo apt-get update && sudo apt-get install vnc4server
Now start up vncserver temporarily so it generates files it needs to run (this will only happen on the initial run)
$ vncserver
You will get prompted for a password that will be used to connect via VNC. Note that anything that’s over 8 characters will be truncated so I suggest using something shorter (between 6 and 8 characters).
When the setup is complete, shutdown the vncserver so we can make some changes:
$ vncserver -kill :1
Now you’re ready to perform one of the following steps depending on your needs:
1. Minimal Gnome desktop:
$ sudo apt-get install --no-install-recommends gnome-core gnome-session-fallback
Edit the generated ~/.vnc/xstartup:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
gnome-session –session=gnome-classic &
[ -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 &
2. Minimal Ubuntu desktop:
$ sudo apt-get install --no-install-recommends ubuntu-desktop
Edit the generated ~/.vnc/xstartup:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
. /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" &
#x-window-manager &
3. Firefox only (the most light weight solution if you just need access to a browser):
$ sudo apt-get install firefox
Edit the generated ~/.vnc/xstartup:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
. /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" &
#x-window-manager &
Once you’ve installed one
On the Mac
Open the “Screen Sharing” app via command line:
open vnc://your_ip:your_vnc_display_number
For example:
open vnc://192.168.0.99:5901
You can also accomplish the above by opening Finder > Go > Connect to server…