Remote Desktop over SSH with macOS
Published 2021-11-9Remote Screen Sharing on macOS is actually just VNC on port 5900. It's insecure by default - intended for local network sharing. Here's how you enable it and share it via ssh:
- Turn on Screen Sharing on the Host (the computer you want to connect to)
- Edit
~/.ssh/config
on the Guest (the computer you connect from) to forward ssh over 5900Host foobar foobar.local LocalForward 5900 localhost:5900
- Connect via ssh from the Guest to the host
ssh foobar.local
- Open Finder on the Guest and hit Cmd ⌘ + K or select Go => Connect to Server
- Connect to localhost (where the ports are forwarded locally)
Also of interest:
- Access web pages through your home network via SSH
- How to Mirror Your iPhone Screen to Mac
- Connect iPhone via USB
- Open QuickTime, New Movie Recording
- Select iPhone as video source
My personal setup
I have mine set up to work locally or over the internet.
Here's my ~/.ssh/config
(also includes a SOCKS5 proxy):
#
# Hostname aliases
#
Host foobar
Hostname foobar.local
Host foobar.ip
Hostname foobar.duckdns.org
#
# Host-specific config
#
Host foobar.ip foobar foobar.local
User myusername
# macOS Finder's built-in VNC Screen Sharing
LocalForward 5900 localhost:5900
# Socks Proxy
DynamicForward 6789
By AJ ONeal
Thanks!
It's really motivating to know that people like you are benefiting
from what I'm doing and want more of it. :)
Did I make your day?
Buy me a coffee
(you can learn about the bigger picture I'm working towards on my patreon page )