Quick Tip: One-touch Screen Sharing

One of the most-used buttons on my Stream Deck is a one-touch connection to the Mac mini server sitting in a closet in my house. I’m frequently popping in to manage files on my RAID, or reconfigure a script that’s fed by my weather station, all sorts of odd jobs.
Beginning with macOS Sonoma, the built-in Screen Sharing on macOS has gotten really good, with support for a high-quality stream and even multiple virtual displays. But connecting to another Mac on your local network via Screen Sharing can be a bit fiddly. Here’s how to make it easy.
First, you’ll need to connect. The easiest way to do this is to open Finder, choose Network from the Go menu, double-click on the Mac you want to connect with on your local network, and then click Share Screen. (If you don’t see the Mac in the Network window, you may not be on the same network or it might not have Screen Sharing turned on. To turn it on, open System Settings, search for Sharing, and then turn on Screen Sharing.)
You’ll be asked to log in with a user name and password (you’ll want the ones that grant you access to that Mac, not the ones on the Mac you’re using to connect), and then you’ll be prompted to choose if you want to use high-quality sharing and how many virtual displays to use. (If you’re on a local network, be sure to turn on the high-quality mode.)
Once you’ve connected, you’ll see that Mac’s screen in a window. Now here’s the sneaky part: Under the Connection menu in the Screen Sharing app, choose Save As. This will save a .vncloc document to your Mac. Later, after you’ve closed the Screen Sharing window, you can re-establish that session by double-clicking this file. it’ll automatically connect you back to the server, and all you’ll have to do is re-enter in the user name and password.
That’s a nice shortcut, but it can get better. If you use a text editor like BBEdit or TextEdit to open that document, you’ll find that it’s the special kind of text file Apple uses to store preferences—a property list.
Now, everyone who is extremely concerned about passwords being stored in insecure ways should close their browser window and forget you ever read this article.
Okay, we’re safe now.
You can embed the user name and the password in the .vncloc document, at which point it will open your session with just a double-click. Toward the top of the file, there’s a line that says <key>URL</key>. On the next line, surrounded by <string> tags, there’s the URL for the screen sharing connection, starting with vnc://.
A little-known (and hated by people who care about password security) trick in the URL specification is that you can embed a user name and password in any URL. The format is:
protocol://username:password@name-of-computer
So if I edit that VNC URL in the property list to begin vnc://jsnell:mycoolpassword followed by the Mac’s address, and then save the file, it will automatically connect and log me in when I double-click.1 A step saved. And the .vncloc document contains a bunch of additional information based on your session preferences, so if you’re using something other than the defaults, this is a nice way to lock all that in. You can take the .vncloc file, give it a nice name and icon, and put it in your Dock or launch it from a launcher utility or even just leave it out on your desktop.
Here’s another second secret: the Stream Deck has a “website” option that will open any arbitrary URL when you click on it. The format of the URL in the .vncloc document gives away what you need to do to form a proper VNC URL:
vnc://username:password@name-of-a-mac.local?quality=5&numVirtualDisplays=1
If you paste that URL (with all the proper names and passwords swapped in for my placeholders) into Safari, it should ask you if you want to open it in Screen Sharing. If I paste that URL into Stream Deck’s website option, then it will launch Screen Sharing and connect without any .vncloc file at all.
In my case, I prefer to use the .vncloc file method because it does lock in all my other preferred Screen Sharing settings. I added the Stream Deck’s Open command, pointed it at the file, and presto—one touch brings my server up on my screen, no additional interaction needed.
- As my pal Dan Sturm points out, if your password contains special characters like spaces, you’ll need to escape them using a simple tool like this one. ↩
If you appreciate articles like this one, support us by becoming a Six Colors subscriber. Subscribers get access to an exclusive podcast, members-only stories, and a special community.