Home › Knowledge base › macOS › How to Configure SSH on macOS KNOWLEDGE BASE
How to Configure SSH on macOS
MACOS

How to Configure SSH on macOS

SKYLINE Knowledge Base
Photo by Carl Heyerdahl on Unsplash

A field-tested, step-by-step guide. How to Configure SSH on macOS — prerequisites, the actual commands, verification, and links to related macOS topics.

macOS has an OpenSSH server built in — disabled by default. Turning it on takes a single Settings toggle, but the production-shaped recipe involves keys, a hardened config, and (optionally) a port move to cut log noise.

Prerequisites

  • macOS 12 Monterey or newer with an admin account.
  • A workstation with an Ed25519 SSH key ready.

Step 1: Enable Remote Login

Two paths — pick one:

GUI: System Settings → General → Sharing → Remote Login → toggle on.

CLI:

sudo systemsetup -setremotelogin on
sudo systemsetup -getremotelogin

By default this enables key + password auth on port 22.

Step 2: Push your SSH key

From your workstation:

ssh-copy-id you@mac.local

If ssh-copy-id is missing on the source machine:

cat ~/.ssh/id_ed25519.pub | ssh you@mac.local "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

Then verify:

ssh -o PasswordAuthentication=no you@mac.local whoami

Step 3: Harden sshd_config

/etc/ssh/sshd_config.d/99-skyline.conf:

PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
ChallengeResponseAuthentication no
PubkeyAuthentication yes
PermitEmptyPasswords no
MaxAuthTries 3
LoginGraceTime 30
X11Forwarding no

macOS uses launchd, not systemd. Reload sshd by toggling Remote Login:

sudo systemsetup -setremotelogin off
sudo systemsetup -setremotelogin on

Or, directly:

sudo launchctl bootout system /System/Library/LaunchDaemons/ssh.plist 2>/dev/null
sudo launchctl bootstrap system /System/Library/LaunchDaemons/ssh.plist

Validate syntax first:

sudo /usr/sbin/sshd -t

Step 4: Restrict who can SSH

By default any administrator can log in via SSH. To restrict to specific users:

sudo dseditgroup -o create -q com.apple.access_ssh
sudo dseditgroup -o edit -a yourusername -t user com.apple.access_ssh

System Settings now shows "Allow access for: Only these users".

Step 5: Optionally move SSH off port 22

Cuts brute-force log noise. Edit /etc/ssh/sshd_config.d/99-skyline.conf:

Port 2222

Reload sshd (Step 3 commands) and open the new port through the macOS firewall:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

The macOS Application Firewall is app-based not port-based, so as long as sshd is allowed (it is by default), you are fine.

Step 6: Use SSH config aliases for daily ops

~/.ssh/config on your workstation:

Host mac
    HostName mac.local
    User ops
    Port 2222
    IdentityFile ~/.ssh/id_ed25519
    ServerAliveInterval 30
ssh mac

Verify

sudo /usr/sbin/sshd -t                # syntax
sudo launchctl print system/com.openssh.sshd | head
sudo log show --predicate 'process == "sshd"' --last 1h | tail -20

Conclusion

OpenSSH on macOS is the same battle-tested daemon you know from Linux, with a slightly different reload story (launchd, not systemd). Key-only access + a group restriction + an optional port move is enough hardening for any small fleet.

Next steps

SKYLINE Engineering

@skyline

The engineering team at SKYLINE Industrial Solutions. We publish field-tested guides drawn from real KSA and GCC deployments.

See author profile
SKYLINE engineering services

Need this implemented for you?

Reading is free — building it right takes a team. SKYLINE engineers ship macOS for Aramco vendors, banks, hospitals and government agencies across Saudi Arabia. Talk to us before you start.

Aramco Approved Contractor ISO 9001 · ISO 27001 SAMA CSF aligned NCA ECC ready 247+ KSA clients

Comments

0 total · 0 threads
Be the first to leave a comment.