SSH Server Setup on Mac

Enabling SSH Access on Mac Using Terminal

Follow these steps to enable SSH access on your Mac entirely via the terminal.

1. Enable Remote Login (SSH)

Run the following command to turn on SSH:

sudo systemsetup -setremotelogin on

Verify SSH is enabled:

sudo systemsetup -getremotelogin

2. Allow SSH Through the macOS Firewall

If your firewall is active, allow SSH connections by executing:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/sbin/sshd
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /usr/sbin/sshd

3. Test the SSH Connection

From another machine, try connecting via SSH:

ssh your_username@your_mac_ip_address

Replace your_username and your_mac_ip_address with your actual Mac username and IP address.


Children
  1. Disable Password Auth (SSH Server MAC)

Backlinks