212

How do you run a ssh server on Mac OS X?

4 Answers 4

263

Go to System Preferences -> Sharing, enable Remote Login.

2
  • 4
    ... and make sure the user is included in "Allow access for" -.-
    – d4Rk
    Commented Nov 4, 2014 at 21:55
  • 5
    sudo systemsetup -setremotelogin on Commented May 7, 2020 at 7:44
69

In System Preferences under Sharing, there is an option for Remote Login.

This will run sshd at startup (through launchd) and enable SSH access with standard options. To tweak the sshd options, edit /etc/sshd_config (or /private/etc/ssh/sshd_config in later versions) (you'll need to do this in a sudo shell or via sudo vi /etc/sshd_config).

3
  • 4
    Unfortunately, that config file won't allow you to edit the port used. To change the port, see serverfault.com/a/67616/102900. Commented Oct 23, 2013 at 17:08
  • 1
    To restart ssh, turn Remote login off, and then turn it back on. No restart is required. Commented Jun 7, 2016 at 13:40
  • 6
    OpenSSH sshd_config file is in /etc/ssh/sshd_config, never see it in /etc on any Linux distro or UNIX-like systems.
    – Terry Wang
    Commented Apr 16, 2020 at 0:03
9

I'd prefer:

sudo systemsetup -setremotelogin on 
1
  • 5
    Turning Remote Login on or off requires Full Disk Access privileges
    – Att Righ
    Commented Jun 16, 2022 at 21:39
0

To provide a full answer for users who prefer a terminal¹ solution:

sudo systemsetup -setremotelogin on 

When you receive the following error message:

Turning Remote Login on or off requires Full Disk Access privileges

Go to Settings > Security & Privacy > Privacy > Full Disk Access; then select Applications > Utilities > Terminal from the file picker². Then execute the command again, it should be in the history so you might just need to press arrow upwards.

You should be able to login with your password, but you should configure SSH key based authentication instead and/or add 2FA. Not sure how to do this on the Mac right now³.

Relevant links:


  1. Not a terminal only solution at the moment and I am a first time Mac user. Wondering why this is not on Ask different, oh it's from 2010, that my be the reason why.
  2. I see the need for improving security, but the ways of thinking and navigating around the user interface (and getting things done) is not really an improvement over Windows for me as a Linux user. Sure everything looks very nice, but to get things done the people I work among install brew and GNU tools... to praise the Mac for it's software quality? Oh come on. I really expected more.
  3. It works on the Mac VM I set up with Quickemu to play around there before breaking my employers Mac accidentally.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .