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.
Prerequisites
1) User access with administrator’s rights on your remote OS X computer.
2) An Secure Shell (SSH) client on your local computer. On Windows, Putty is a common and free version. Linux and MAC OS X, by default, come with SSH.
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
Tags: MAC Remote Desktop, OS X Leopard, OS X Screen Sharing, Putty, Remote Login, Security, SSH, VNC
Awesome! I was looking for the command-line to turn on normal VNC access!
You don’t even need a 3rd party VNC client.
The built-in (but hidden) client in OS X Leopard can be found at
/System/Library/CoreServices/ScreenSharing.app
Just run that (I dragged it to the dock), and enter the remote hostname. It will prompt you for your password on the host, and voila!
Hey Ryan, awesome page!
brilliant tip! help me a lot!
thanks for this! This is perfect for what I needed…
You’re a lifesaver!!
Just to clarify, this actually enables Remote Management, which also enables Screen Sharing, but it doesn’t enable Screen Sharing alone.
Do you have the terminal command to enable and configure Screen Sharing alone?
I know for 10.6 you can enable Screen Sharing via:
sudo echo enabled > /private/etc/ScreenSharing.launchd
I just am not sure how to configure (password/user access, etc).
JRH