Today I Learned

A Hashrocket project

Remotely control your desktop over ssh on macOS

Using ssh port forwarding and vnc you can connect to your remote desktop using the Screen Sharing application.

First connect to your machine over ssh and port forward 5900.

ssh user@machine.somehwere -L 5900:localhost:5900

Then in another terminal, on your local machine, open Screen Sharing by passing a open a vnc url.

open 'vnc://localhost'

Screen Sharing should open and ask you for credentials for the remote machine. And then you do cool things on your remote desktop!

Read more about VNC here in this wikipedia article.

Hat Tip to Dorian Karter!