Guides · September 2026

Remote Login on a Mac, set up properly

What the switch actually starts, how to turn it on from Settings or a terminal, how to keep it to keys and named users, and what to do when the connection is refused.

What Remote Login is.

Remote Login is the Sharing switch that starts macOS’s SSH server. Turn it on and the Mac listens on TCP port 22 for SSH, and with it SFTP and scp, because they ride the same service — Apple’s port list files all three under 22. Anyone who can reach that port with a Mac account or a key you have authorized gets a shell as that user. The server is OpenSSH, the same one every Linux box runs, so everything you know about ssh applies.

Two macOS-specific details. The switch has an “Allow full disk access for remote users” option, because macOS protects folders like Desktop and Documents from processes that have not been granted access, and an SSH session is one; leave it off until a job needs it. And since macOS Tahoe 26, a FileVault-encrypted Mac can be unlocked over ssh after a restart if Remote Login is on and the network is up — the first time a headless Mac with FileVault has been manageable from a distance.

Turn it on.

The paths are macOS Tahoe 26; Ventura onward has the same pane.

  1. 01Flip the switch.

    Apple menu > System Settings, General in the sidebar, then Sharing. Click the info button next to Remote Login and turn it on. The pane shows the line another machine uses to reach you, ssh you@hostname, with the Mac’s .local name filled in (Apple’s guide).

  2. 02Or do it from a terminal.

    The same switch from a shell, for scripting a fresh Mac. systemsetup needs an administrator; the second line reports the state.

    sudo systemsetup -setremotelogin on sudo systemsetup -getremotelogin
  3. 03Restrict who may log in.

    Under Allow access for, choose Only these users and add the accounts that need a shell. Behind the menu is a local group, com.apple.access_ssh: sshd admits its members and refuses everyone else. From a terminal the same restriction is a dseditgroup call; the ManageMacs wiki-or-Remote-Login) documents the group and its “-disabled” rename under All users.

    sudo dseditgroup -o edit -a you -t user com.apple.access_ssh
  4. 04Put a key on the Mac.

    On the machine you will connect from, make a key if you have none and put its public half in ~/.ssh/authorized_keys on the Mac — ssh-copy-id where it exists, the manual form anywhere. Permissions matter to sshd: ~/.ssh must be 700 and authorized_keys 600, or the key is silently ignored. On a Mac client, ssh-add --apple-use-keychain keeps the passphrase in the keychain.

    ssh-keygen -t ed25519 ssh-copy-id you@your-mac.local # or, without ssh-copy-id: cat ~/.ssh/id_ed25519.pub | ssh you@your-mac.local \ 'mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'
  5. 05Close the password door.

    Once the key works, turn passwords off in /etc/ssh/sshd_config on the Mac. macOS accepts passwords through keyboard-interactive as well as the plain method, so both lines are needed. Toggle Remote Login off and on afterwards, and test from a second terminal before closing the one you are in.

    PasswordAuthentication no KbdInteractiveAuthentication no
    /etc/ssh/sshd_config
  6. 06Check the firewall and the sleep settings.

    The firewall is under System Settings > Network > Firewall. With “Automatically allow built-in software to receive incoming connections” on — the default — sshd is admitted; with “Block all incoming connections” on, Apple’s firewall guide says connections to all other sharing services are prevented, and Remote Login stops answering with its switch still on. Then make sure the Mac is awake to answer: “Wake for network access” under Energy on a desktop, or Battery > Options on a laptop, power adapter only.

Connect from a Mac, a PC, or a phone.

From another Mac or a Linux machine, it is the line the Sharing pane showed you: ssh you@your-mac.local. The .local name is resolved by Bonjour and works only on the same network; elsewhere use the address or a name you control. The first connection shows the Mac’s host key fingerprint and asks you to accept it; that is how your client recognises the Mac from then on.

Windows 10 and 11 carry Microsoft’s OpenSSH client as an optional feature, usually already present — ssh works from PowerShell, and Microsoft’s OpenSSH guide covers adding it. From a phone, any SSH app reaches Remote Login with the same account or key; SSH from an iPhone covers the apps, and the honest summary is small type and a session that ends when the app is backgrounded.

Reaching it from outside your network.

Remote Login makes the Mac listen; it does nothing to make it reachable. On your own Wi-Fi the two coincide; from anywhere else your router’s NAT stands in the way, and you have three honest options. Forward TCP 22 from the router to the Mac, which puts sshd on the public internet: fine with keys only and named users, reckless with passwords, dependent on dynamic DNS to find your changing home address, and impossible behind carrier-grade NAT, where you have no public address to forward from.

Or put the Mac on a private network: Tailscale and its peers give the Mac and your other devices addresses that reach each other across NAT without forwarding, and Remote Login answers on the tailnet address as it does on the LAN, for the price of a client on every device. Or use something that never needs the Mac to listen at all — where this page turns, below.

When it fails.

Each of these is the text ssh prints, and each has a short list of causes.

Connection refused

Nothing is listening where you knocked. Remote Login is off, the firewall is set to block all incoming connections, or you reached a different machine. Check sudo systemsetup -getremotelogin on the Mac and the firewall pane; if both are right, confirm the name resolves to the Mac you think it does.

Connection timed out

The packets never arrived. Usually you are off the LAN and nothing forwards port 22, or a .local name is being used across networks where Bonjour cannot resolve it. On the LAN, a sleeping Mac produces the same symptom — see the wake settings above.

Permission denied (publickey,password,keyboard-interactive)

The Mac answered and turned you away. The account is not in Only these users, the public key is not in that user’s authorized_keys, or the permissions on ~/.ssh are too open and sshd is ignoring the file. ssh -v shows which keys the client offered and which the server declined.

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

The Mac’s host key no longer matches the one your client saved. After a clean reinstall, or a new Mac inheriting the old name, that is expected: ssh-keygen -R your-mac.local forgets the old key. If nothing on the Mac changed, stop and find out why before you accept a new one.

Operation not permitted, on a folder you own

The session logs in but cannot read Desktop, Documents, or another protected folder: that is the full disk access switch in the Remote Login options, off by design. Turn it on for the job and off afterwards.

Remote Login opens a listener. There is another shape.

Everything above is the right way to run SSH on a Mac, and at home with keys and a named user it is a good way to live. Its two limits are structural. The Mac must listen, so reaching it from outside means a forward or a VPN and a client on every device. And a session belongs to the connection: close the laptop, lose the train’s Wi-Fi, background the app on the phone, and the shell — with the build or the agent in it — is gone unless you remembered tmux.

spawnd inverts both. One daemon runs on the Mac and dials out; nothing listens on the host, no port is forwarded, no VPN is needed. A worker process on the Mac owns each session’s PTY, so a session survives the closed tab, the dropped connection, the laptop lid, and a daemon restart, scrollback intact. Any browser is the console, and on a phone it installs to the home screen as a web app — no client app, no keys on the device; a new device is approved once against a short code, and revoking it is one click every host honors. Your browser talks to each daemon peer-to-peer, end-to-end encrypted, and the server that introduces them never sees session content. Remote Login can stay on beside it for scp and the tools that expect a port, or go off. If you stay with SSH, the tmux cheatsheet is the persistence half of that route; remote access to your Mac puts every method, this one included, side by side.

Start

One line on the Mac. No port 22.

$curl -fsSL https://spawnd.dev/install.sh | sh
Sign up free
Install the daemon

Questions

Is it safe to leave Remote Login on?
On a home network with key-only authentication and Only these users, yes; sshd is the most scrutinised listener there is. The risk is forwarding port 22 to the internet with passwords still enabled, where automated guessing starts within minutes.
Does Remote Login let me copy files to and from the Mac?
Yes. SFTP and scp use the same service and the same port, so any SFTP client or scp works with the login you already have. The full disk access switch decides whether protected folders are readable.
Can I SSH into the Mac before anyone logs in after a restart?
Since macOS Tahoe 26, yes: with Remote Login on and a network connection, a FileVault-encrypted Mac accepts an ssh login after a restart so an administrator can unlock the disk and let the boot finish. Earlier versions needed someone at the keyboard.