How do I set up VNC with Mac OSX?
Could you help me with connecting to a Linode using VNC Viewer (Ubuntu 19.04) from Mac OSX?
Sure, I'd be happy to help!
Before you begin
Before you begin, I would suggest updating your system using the command:
sudo apt-get update && sudo apt-get upgrade. I would also suggest reviewing our Getting Started guide and complete the steps for setting up your Linode's hostname and timezone. Further, please refer to our Securing Your Server guide to create a standard user account, harden SSH access, and remove unnecessary network services.
Installing a desktop and VNC Server on your Linode
- Ubuntu has several desktop environments available in its repositories. The following command installs the default desktop, Unity, as well as the dependencies that are required for the graphical interface to work properly:
sudo apt-get install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
Note: Please keep in mind that this command will install the full Ubuntu desktop environment, including office and browsing tools. To install a bare desktop without these packages, run:
sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
During the install process, you will be asked whether or not to change a file to the new version:
Configuration file '/etc/init/tty1.conf' ==> File on system created by you or by a script. ==> File also in package provided by package maintainer. What would you like to do about it ? Your options are: Y or I : install the package maintainer's version N or O : keep your currently-installed version D : show the differences between the versions Z : start a shell to examine the situation The default action is to keep your current version. *** tty1.conf (Y/I/N/O/D/Z) [default=N] ?
Type Y then press enter to use the updated version.
- Install the VNC server:
sudo apt-get install vnc4server
Securing your VNC connection
The VNC Server generates a display, or graphical output, identified by a number that is defined when the server starts. If no display number is defined, the server will use the lowest one available. VNC connections take place on port
5900 + display. This guide will use a display number of 1; therefore, you will connect to port 5901.
The default VNC connection is unencrypted. In order to secure your passwords and data, you will need to tunnel the traffic through an SSH connection to a local port. You can use the same local port for consistency.
Connecting Linode to Mac OS X
- From your desktop, connect to your Linode with the following command. Be sure to replace
firstname.lastname@example.org your username and your Linode's hostname or IP address:
ssh -L 5901:127.0.0.1:5901 email@example.com
- From your Linode, launch the VNC server to test your connection:
vncserver :1You will be prompted to set a password.
Connect to VNC from your Desktop (Mac OS X)
While there are many options for VNC Viewer clients, this guide will use RealVNC Viewer
- After installing and opening the viewer, connect to the localhost through your VNC client. The format is
#is the display number we used in the previous section, Secure your VNC connection.
- You will be warned that the connection is unencrypted, but if you have followed the steps above for securing your VNC connection, your session will be securely tunneled to your Linode. To proceed, press Continue.
- You will be prompted to enter the password you specified when first launching the VNC Server on your Linode.
After connecting, you will see a blank gray screen since the desktop processes have not yet been started.
Configure VNC for a full desktop
Once you've successfully connected, exit the connection. Close the VNC server using this command:
vncserver -kill :1
Edit the end of your
~/.vnc/xstartupfile to match the following configuration. This starts the desktop dependencies as background processes upon starting the VNC server:
#!/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 & x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & x-window-manager & gnome-panel & gnome-settings-daemon & metacity & nautilus &
Save and exit the file. Begin another VNC session:
Connect from your local VNC client using the same steps from the previous section, Connect to VNC from your Desktop (Mac OS X).
For more information on this process, please refer to our guide for Installing VNC on Ubuntu. Please note: The guide refers to Ubuntu 18.04, but I was able to successfully set up VNC on Ubuntu 19.04 using that guide.