VNC – setup for MacOS

Getting started with VNC – remote access desktop – for MacOS users

Step 1: If working remotely and VPN is not already installed on your notebook, computer:

MacOS has a native built-in VNC (remote desktop).

Example. use VNC to connect to Linux workstation desktop hostname: pluto

Step 2: If you do not have a VNC password or if this is the first time running VNC, you’ll need to create a VNC login password

  • On your MacOS computer, open a terminal window
  • enter: ssh username@pluto
  • enter: vncpasswd

Step 3: If a vnc session is not running, start a new vnc session running on: pluto

  • On your MacOS computer, open a terminal window
  • enter: ssh username@pluto
  • start vnc, enter: vncserver
  • this should display the message: pluto:X
    where “X” will be a vnc session # number

Step 4: To connect to your vnc session

On your MacOS computer, at the top of MacOS desktop, in the window frame

Apple-icon — Finder — File —- Edit —- Go —– Window —- Help

  • Click on: Go (a pull down menu will appear)
  • select: Connect to Server (this is at the bottom of the pull down)
  • In the input box, enter: vnc://pluto:590x
    where “x” = the vnc session # number, from vncserver
  • select: Connect

Step 5: A small login window will appear on your desktop, enter your VNC password
to connect to the VNC server on “pluto”


 –

Note 1: VNC xstartup

When starting VNC, VNC reads the file: /home/<username>/.vnc/xstartup

A minimal xstartup file is created the first time the user run vncserver; however users may need to customize their file.

In order for clipboard copy and paste to work, the user must run vncconfig in the background. This utility creates the bridge to the Window’s copy and paste clipboard. It can be run manually or included in the xstartup file.

Sample file: /home/<username>/.vnc/xstartup

#!/bin/sh

#for RHEL/CentOS 7

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
vncconfig -iconic &
exec /etc/X11/xinit/xinitrc

Sample file: /home/<username>/.vnc/xstartup (if mate desktop is available)

#!/bin/sh

# for RHEL/CentOS 6

if [ -f /usr/bin/mate-session ]; then
  unset SESSION_MANAGER
  unset DBUS_SESSION_BUS_ADDRESS
  /usr/bin/mate-session

  [ -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 &
else
  gnome-session &
fi
 

Note 2:

The Xvnc server and GNOME desktop session will run persistently.
That is, the session runs until you either kill or terminate the session –

example: vncserver -kill :X

where “X” = vnc session # number

vncserver -kill :3

or reboot pluto . You can freely disconnect and reconnect to the
remote session without terminating your VNC session.

If the GNOME desktop session hangs, kill the Xvnc server and start a new VNC session.

Note 3:

VNC Gnome desktop, how to open a terminal window ( Applications -> System Tools )

  • Select “Terminal” ( GNOME terminal; white background, black text )
  • Select: “MATE Terminal” ( black background, white text )
  • Do not select: “Xterm” – this can freeze your VNC session (known issue)

ref. https://discussions.apple.com/thread/7445310