When a Mac mini moves into a closet to run builds or agents around the clock, the first thing you lose is the keyboard. From then on every fix happens over the network, so the way you enable SSH on the Mac decides whether a bad night ends with one command or a walk to the closet with a spare monitor.
macOS ships OpenSSH, but the switch is called Remote Login, and the Terminal route most guides give now fails with a Full Disk Access error. Every step below was tested in November 2026 on a macOS 27.2 machine we named build-mini, driven from a second Mac. The power capabilities come from an AWS-hosted M4 Mac mini, read without changing anything.
This guide turns on Remote Login both ways, moves you to key-only logins, hardens sshd with a drop-in file, carries Screen Sharing through an SSH tunnel and keeps the machine awake and reachable after a power cut.
Turning on Remote Login in System Settings
Remote Login is Apple’s name for the OpenSSH server, and it lives under System Settings > General > Sharing. Scroll to the Advanced group at the bottom. On our test machine it sat between Remote Management and Remote Application Scripting, switched off, with the Local hostname shown underneath it.

- 1Remote Login switch
- 2Info button for the options
Flip the Remote Login switch and macOS asks for an administrator password before it changes the setting. Then click its info button for the options, because the defaults on that panel matter more than the switch. Note the Local hostname line as well: build-mini.local is the name you’ll type from the workstation, and it resolves over Bonjour without any DNS work.

- 1Allow access for
- 2Full disk access for SSH sessions
The panel holds three things worth reading before you click Done.
- The ready-made
sshcommand under “Remote Login: On” - Allow full disk access for remote users, off by default
- Allow access for, which on our machine read “Only these users: Administrators”
Leave full disk access for SSH sessions off unless a backup or sync job you run over SSH needs to read protected folders such as Mail or Messages. The access list is your first filter: a standard account is not in Administrators, so it cannot log in over SSH until you add it here. Apple’s own Remote Login help page covers the same panel, and the rest of this guide tightens what it leaves open.
Turning on Remote Login from Terminal
You’ll want the Terminal route when you’re working over Screen Sharing on a Mac that’s already in the closet, or when you’re scripting a fleet. The command every older guide gives is systemsetup -setremotelogin on, and on current macOS it fails even with sudo. The read side still works, so start there and see what state the Mac is in.
sudo systemsetup -getremotelogin
It reports the current state in one line.
Remote Login: Off
Now try to change it the old way, which is where it goes wrong.
sudo systemsetup -setremotelogin on
On our machine the write was refused, and the exit code was 1.
setremotelogin: Turning Remote Login on or off requires Full Disk Access privileges.
Full Disk Access is a privacy permission granted to the app running the shell, so sudo doesn’t supply it. You could grant Terminal Full Disk Access in Privacy & Security, but that is a broad grant to hand out for one switch. The sshd job itself is a plain launchd daemon, so we enabled and loaded it directly:
sudo launchctl enable system/com.openssh.sshd
sudo launchctl bootstrap system /System/Library/LaunchDaemons/ssh.plist
Both commands returned silently with exit code 0, systemsetup -getremotelogin now reported Remote Login: On, and launchctl print-disabled system listed the job as enabled.

Before you rely on it, check the port from the workstation with nc -zv build-mini.local 22. Ours answered with Connection to build-mini.local port 22 [tcp/ssh] succeeded!, while an ssh attempt with Remote Login off had failed with Connection refused.
Setting up key-only login from your workstation
Passwords over SSH are the weak spot on any always-on box, and on a Mac they’re the same password that unlocks the account and its keychain. So the plan is a key with a passphrase on the workstation, copied once while password login still works. Our workstation was another Mac, which is why the paths below show /Users/ec2-user; yours will show your own account.
ssh-keygen -t ed25519 -C "mary@laptop"
Accept the default path and set a passphrase when asked, because a stolen laptop with an unprotected key is a stolen Mac mini too. The fingerprint is unique to every key.
Generating public/private ed25519 key pair.
Enter file in which to save the key (/Users/ec2-user/.ssh/id_ed25519):
Enter passphrase for "/Users/ec2-user/.ssh/id_ed25519" (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/ec2-user/.ssh/id_ed25519
Your public key has been saved in /Users/ec2-user/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:qMOato46F7IR5GTW6yxa6/RqZbVziWY48ZISVT0Buso mary@laptop
Load the key into the agent with ssh-add so you type the passphrase once per session, then push the public half to the Mac mini. ssh-copy-id ships with macOS, so there’s nothing to install:
ssh-copy-id [email protected]
This is also your first connection, so OpenSSH shows the server’s host key fingerprint and waits for a yes. Answering yes blindly is how people end up trusting the wrong machine.

To check that fingerprint honestly, read it on the Mac mini itself while you still have the console. A session through the SSH tunnel later in this guide doesn’t count, because it already trusts the key you’re checking.
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
Ours matched the prompt character for character, ending in ti4mV0.
256 SHA256:+5/x06NnIxLuUAhlwD7oo5IEV3KR37gqnojrjti4mV0 no comment (ED25519)
Typing [email protected] gets old fast, so give the box a short alias in ~/.ssh/config on the workstation. UseKeychain is an Apple addition to OpenSSH that stores the key’s passphrase in your login keychain, and ServerAliveInterval keeps idle sessions from being dropped by home routers:
vim ~/.ssh/config
Add the host block. The file does not exist until you create it, and UseKeychain only works with Apple’s own ssh; Homebrew’s OpenSSH rejects it unless you put IgnoreUnknown UseKeychain above it.
Host build-mini
HostName build-mini.local
User mary
IdentityFile ~/.ssh/id_ed25519
AddKeysToAgent yes
UseKeychain yes
ServerAliveInterval 30
Now ssh build-mini is the whole command. Our first run printed build-mini and 27.2 for hostname; sw_vers -productVersion with no password prompt, which is the proof the key took. More tricks for that file live in our guide to managing SSH connections with an SSH config file, and if you’d rather keep the private key on hardware, the same Mac client works with FIDO2 security keys for SSH.
Hardening sshd_config with a drop-in file
With a key in place, password logins only help attackers. Don’t edit /etc/ssh/sshd_config itself; keep your changes in a file of your own that’s easy to find and remove. Line 19 of that file includes /etc/ssh/sshd_config.d/*, and Apple’s own 100-macos.conf already lives there setting UsePAM yes. Before changing anything, we read what the daemon actually runs with.
sudo sshd -T | grep -iE "^(passwordauthentication|kbdinteractiveauthentication|permitrootlogin|pubkeyauthentication|usepam|allowusers|maxauthtries|x11forwarding|allowtcpforwarding)"
Both password paths were open by default and no AllowUsers line existed, so any account in the access list could try a password.
UsePAM yes
MaxAuthTries 6
PermitRootLogin prohibit-password
PubkeyAuthentication yes
PasswordAuthentication yes
KbdInteractiveAuthentication yes
X11Forwarding no
AllowTcpForwarding yes
Keep a second session open on the Mac mini while you do this. If the new file locks you out, that session is how you delete it, and without it the only way back is a monitor and keyboard in the closet. With that session open, create the drop-in.
sudo vim /etc/ssh/sshd_config.d/200-hardening.conf
Put these lines in it, with your own account name after AllowUsers.
# Key-only SSH for build-mini
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
AllowUsers mary
MaxAuthTries 3
Both password lines matter. KbdInteractiveAuthentication is the path PAM uses to ask for a password, so turning off only PasswordAuthentication leaves a password prompt alive. OpenSSH keeps the first value it reads for each option, and the include runs before the main file’s own settings, so the drop-in wins. Test the syntax before anything else:
sudo sshd -t
No output and exit code 0 means the file parsed. Then read the effective values again to confirm the drop-in is the one in charge:
sudo sshd -T | grep -iE "^(passwordauthentication|kbdinteractiveauthentication|permitrootlogin|allowusers|maxauthtries)"
All five lines came back with the new values.
MaxAuthTries 3
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
AllowUsers mary
A restart is optional here. On macOS, launchd holds port 22 and starts a fresh sshd for every connection; launchctl print system/com.openssh.sshd on our box showed state = not running and the inetd-compatible property between logins. So the next connection reads the new file, which is exactly why sshd -t comes first. We still ran sudo launchctl kickstart -k system/com.openssh.sshd (exit code 0) before testing, and it does no harm. From the workstation, we tried a password login, a login as the other admin account and a normal key login.
ssh -o PubkeyAuthentication=no [email protected]
ssh [email protected]
ssh [email protected] 'echo key login ok as $(whoami) on $(hostname)'
The first forces a password attempt, and the second tries the other admin account, which has no key from this workstation. The third is the normal key login. The terminal below shows what each returned, so you know what a correct refusal looks like.

Both refusals read Permission denied (publickey), which tells you the server no longer even offers a password method. The admin refusal doesn’t prove the AllowUsers line on its own, since that account has no key; the sshd -T output above is what shows AllowUsers mary in force. The key login still answered key login ok as mary on build-mini. If the Mac uses FileVault, Apple’s apple_ssh_and_filevault man page explains that sshd’s configuration sits on the data volume, so before you unlock it after a reboot, password authentication over SSH still works for the unlock itself. Your drop-in takes over once the volume mounts.
Reaching Screen Sharing through an SSH tunnel
Some jobs still need the desktop: a permission dialog, a first-run assistant, an app with no CLI. Screen Sharing sits in the same Sharing pane, and on our image it was already on. Open its info panel and check one switch before you use it.

Leave VNC passwords off by keeping “VNC viewers may control screen with password” switched off. That option adds a separate, short VNC password for third-party viewers, while the macOS viewer logs in with your account. Then forward a local port to the Mac mini’s port 5900 through SSH. The tunnel uses your key, and the VNC traffic rides inside it:
ssh -f -N -L 5901:localhost:5900 build-mini
The -f -N pair sends ssh to the background without opening a shell, so your terminal is free again. Confirm the local end is listening before you open a viewer, because a forward that failed in the background prints nothing.
lsof -nP -iTCP:5901 -sTCP:LISTEN | awk 'NR>1{print $1, $9, $10}'
It bound both loopback addresses and nothing else, so nobody on your network can use the forward:
ssh [::1]:5901 (LISTEN)
ssh 127.0.0.1:5901 (LISTEN)
Now point the viewer at your own machine. On a Mac with a screen, the usual route is open vnc://localhost:5901, which hands the address to Screen Sharing and asks for the Mac mini account’s name and password. Our workstation had no display of its own, so what we tested was vncdotool logging in as mary through the tunnel, and we captured exactly what came back.

- 1Screen Sharing session indicator
- 2Sleep held off by screensharingd
Before you lean on the tunnel for real work, check these points on the Mac mini, because the setup screens alone cost us a retry in the lab.
- Screen Sharing switched on in the Sharing pane
- Your account listed under Allow access for
- That account logged in once, so no setup screens wait
- Port 5900 left out of your router’s port forwards
Two things stood out. Our mary account had never logged in at the Mac, and its session opened on setup screens before the desktop, so it’s worth logging each account in once before you need the desktop in a hurry. And pmset -g inside the session showed sleep prevented by powerd, screensharingd. That is sleep held off by screensharingd, so an open viewer keeps the Mac awake on its own. The menu bar also carries the Screen Sharing session indicator for as long as someone is connected.
We also tried to close port 5900 to the LAN with the macOS firewall’s “Block all incoming connections”. A direct VNC login then timed out, while the tunnel we had opened before the change kept working. Apple’s firewall help says the setting “prevents connections to all other sharing services”, which can include Remote Login, so on a headless Mac a fresh SSH login is at risk the moment the old session closes. Leave it off and keep 5900 out of your router’s port forwards instead. The same -L pattern works for any service on the box, and our guide to local, remote and dynamic SSH tunnels covers the other two forms.
Keeping a headless Mac mini awake and reachable
Everything above is useless if the Mac sleeps at 2 a.m. or stays dark after a power cut. Power policy lives in pmset, and a value of 0 means never. We set it on build-mini for all power sources:
sudo pmset -a sleep 0 disksleep 0 displaysleep 10 womp 1 autorestart 1 powernap 0
The display can still sleep after 10 minutes, since nobody’s looking at it. Read the result back with pmset -g, because what you set is not always what you get.
System-wide power settings:
Currently in use:
powernap 0
SleepServices 0
sleep 0 (sleep prevented by powerd)
Sleep On Power Button 1
ttyskeepawake 1
tcpkeepalive 1
disksleep 0
standby 0
displaysleep 10
Notice what’s missing: womp and autorestart. Our build-mini was a virtual machine, and pmset returned exit code 0 yet both settings were missing afterwards; systemsetup -getrestartpowerfailure answered “Not supported on this machine”. So run pmset -g cap first, which lists what the hardware supports. On the AWS-hosted M4 Mac mini (model Mac16,10) it returned this list, and the list is the point: womp and autorestart are there on real hardware.
Capabilities for AC Power:
displaysleep
disksleep
sleep
womp
autorestart
autorestartatconnect
standby
powernap
ttyskeepawake
tcpkeepalive
lowpowermode
Check your own machine’s pmset -g after setting them, because a value missing from the output didn’t take. The table sums up what each setting buys a closet Mac, with the meanings taken from the SS64 pmset reference.
| Setting | Value | Why a headless Mac wants it |
|---|---|---|
sleep | 0 | The system never idles to sleep, so SSH stays reachable |
autorestart | 1 | Boots again by itself when power returns after an outage |
womp | 1 | Wake on an Ethernet magic packet, so you can wake it remotely |
ttyskeepawake | 1 | An active remote login session holds off idle system sleep |
displaysleep | 10 | Only the screen sleeps; nothing on the network notices |
For a single long job you don’t want to change policy for, caffeinate -i holds off idle sleep until the command it wraps exits. The last trap is FileVault. On current macOS, Apple’s apple_ssh_and_filevault man page says an SSH password login can unlock the data volume after a restart when Remote Login is on, and the session drops briefly while the volume mounts. With autorestart 1 and FileVault on, plan to SSH in once after every outage before your services come back. If you’re still choosing hardware for this, our Mac mini buying guide for 24/7 agent work compares the current models, and a rented EC2 Mac instance is where we ran the workstation side of this lab.