- Either type
open vnc://[host_name]:[port]
in Terminal orvnc://[host_name]:[port]
in Safari or other browser - You can omit
:[port]
if your server is using a default port (5900) - A default Screen Sharing app will open and you can type-in VNC username and password
- Create SSH tunnel to the server:
ssh -L 5900:localhost:5900 [alias]
(see more about SSH here) - This will forward everything from the local port 5900 to the remote port 5900 via SSH tunnel
- Open VNC client:
open vnc://localhost
in Terminal orvnc://localhost
in Safari - You can create an alias in your
~/.zshrc
in order to connect just byvnc
:
alias vnc='/usr/bin/open -a Safari vnc://localhost && ssh -L 5900:localhost:5900 [alias]'
- System Preferences -> Sharing -> Screen Sharing
- Settings -> Sharing -> Remote Desktop
- Enable Legacy VNC Protocol and in three-dot submenu select "require password" (needed for connections from macOS's Screen Sharing app)
- It's not possible to connect when there are no active user sessions (after restart), as a workaround you can enable Automatic Login in Settings -> Users. However, Automatic Login doesn't unlock GNOME Keyring, so VNC will not be able to accept connections, as a workaround you can set empty password for login Keyring in Passwords and Keys. More information: How to Enable Remote Desktop in Ubuntu 22.04
- Additionally, if there is no monitor plugged-in, you have to add fake display - more info
- You may also encounter issues with clients not able to connect via SSH tunnel randomly. In that case verify the connection on the client via
netstat -an | grep 5900
, if you seeFIN_WAIT
orCLOSE_WAIT
in there, it means that your connection isn't properly established. You can try addingServerAliveInterval 60
andServerAliveCountMax 30
to the specific host in your~/.ssh/config
.