Category Archives: VNC

Connect to macOS from Windows

I used to connect to MacOS remote desktop using RealVNC.

I create a local port forward:

ssh -L 25900:127.0.0.1:5900 username@MAC_IP

I was than able to connect using 127.0.0.1:25900. But that stopped working after macOS upgrade. I started getting Key Length Too Large error. RealVNC does not seem to fix it event in latest version 8.5.

So I was looking for alternative client that supports macOS username login. Most clients only seem to support password only login. What worked for me was gvncviewer in WSL. The only problem is that it does not seem to support port change, so I have to use 5900 instead of 25900 for local connection.

sudo apt install gvncviewer
ssh -L 5900:127.0.0.1:5900 username@MAC_IP
gvncviewer 127.0.0.1

Connect to Mac using VNC from Windows using encrypted connection

On Mac you need to enable Remote Login and Screen Sharing.

Note: If Remote Login is not starting with message “Remote Login starting…” you might need to manually add a launch daemon:
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist

On Windows run Powershell and create encrypted SSH tunnel. Replace USERNAME with your user name and MAC_IP_ADDRESS with IP address of your Mac.

ssh -L 25900:127.0.0.1:5900 USERNAME@MAC_IP_ADDRESS

Now use a VNC client (eg. RealVNC Viewer) and connect to 127.0.0.1:25900. RealVNC will still complain about unsecure connection but the connection will be local only (127.0.0.1).

Running UltraVNC repeater under Linux server

I am playing with remote support tools. There are a lot of good payed tools like TeamViewer, GoToMeeting and others but they are expensive. I found that UltraVNC has some tools like Single Click which can make it easy to provide remote support to your customers. Finally I ended by ChunkVNC which is basically UltraVNC but looking much more better.
There is a lot of tutorials on the Internet but they describe direct connection support. Which means at least one of the PC’s has to be accessible from the outside world. But I wanted to setup some server which I would connect to instead of connecting directly to customer’s PC. This server is called Repeater. UltraVNC has a repeater targeting Windows platform. But I have a Linux server and I wanted it to be running there. Fortunately a Linux port of the UltraVNC Repeater is also available. I have created a mirror of the latest version in case the original page won’t work.
The installation itself is not a big problem even though you have to compile the sources.

  1. Connect to the server using SSH
  2. Go to temp: cd /tmp/
  3. Download the sources: wget http://downloads.stefko.cz/uvncrepeater.tar.gz
  4. Extract them: tar zxvf  uvncrepeater.tar.gz
  5. Go to the sources directory: cd uvncrepeater/
  6. Compile the sources: make
  7. Copy repeater to sbin: cp repeater /usr/sbin/repeater
  8. Run it: /usr/sbin/repeater

If you want to make it running as a service you can use the following piece of code:

#! /bin/sh
# vnc: start/stop/restart the VNC repeater server
# chkconfig: 3 20 80
# description: VNC repeater server

vnc_start() {
if [ ! -f /etc/uvncrepeater.ini ]; then
echo "File /etc/uvncrepeater.ini does not exist. Aborting."
exit
fi
/usr/sbin/repeater 2>>/var/log/vnc.log &
pgrep repeater >/var/run/vnc.pid
}

vnc_stop() {
killall repeater
rm /var/run/vnc.pid
}

vnc_restart() {
if [ -r /var/run/vnc.pid ]; then
kill `cat /var/run/vnc.pid`
else
echo "Killing repeater in the absence of /var/run/vnc.pid"
killall repeater
fi
sleep 1
vnc_start
}

case "$1" in
'start')
vnc_start
;;
'stop')
vnc_stop
;;
'restart')
vnc_restart
;;
*)
echo "usage $0 start|stop|restart"
esac

Take the code and save it into /etc/init.d/vnc file on the server. Then run the following commands to install it as a service:

  1. chmod +x /etc/init.d/vnc
  2. chkconfig –add vnc
  3. chkconfig –level 3 vnc on