Enabling Remote Access to Apple OS X Leopard via SSH Command Line
Would you like to access your Apple OS X machine remotely? OS X Leopard has a feature that they call “Screen Sharing”. Those who use Windows and Unix also know this as “VNC”. So you can use a VNC client to view your Mac’s desktop.
Okay, if you’re already at your MAC’s desktop you can simply turn on Screen Sharing. But if you (1) didn’t plan ahead or (2) worry about security, I’d suggest this course of action.
1) User access with administrator’s rights on your remote OS X computer.
3) A VNC viewer client on your local computer. Tight VNC worked for me on Windows (for some reason, UltraVNC and TightVNC didn’t). Ubuntu Linux’s Terminal Server Client worked for me too. Apple OS X should come with the tool.
4) Network access to the SSH service on your remote machine. This requires
a) You know your remote machine’s hostname or IP address.
b) Being behind the firewall, having VPN access, or being accessible to the public Internet (i.e. no firewall).
How to Remotely Turn On (and off) OS X Screen Sharing
This procedure keeps security in mind. The idea is to turn on screen sharing while you need it, and then turn it off when you’re done. Also, the write-ups of Tim Boland and Chris Brewer were very helpful in figuring this out.
1) SSH into your remote OS X machine with an administrator’s log in and password.
2) Enable Remote Desktop (a.k.a. Screen Sharing, a.k.a. VNC) with this command:
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw mypasswd -restart -agent -privs -all
3) Login using a VNC client. As I mentioned, TightVNC worked for me; for some reason, RealVNC and UltraVNC didn’t. Your password is “mypasswd” (see the -vncpw flag in the above command; you can — and should — change this).
4) When you are done, turn of screen sharing using your SSH session:
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off