How do you run a ssh server on Mac OS X?
4 Answers
Go to System Preferences -> Sharing, enable Remote Login.
-
4
-
5
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
).
-
4Unfortunately, that config file won't allow you to edit the port used. To change the port, see serverfault.com/a/67616/102900. Oct 23, 2013 at 17:08
-
1To restart ssh, turn Remote login off, and then turn it back on. No restart is required. Jun 7, 2016 at 13:40
-
6OpenSSH
sshd_config
file is in/etc/ssh/sshd_config
, never see it in/etc
on any Linux distro or UNIX-like systems. Apr 16, 2020 at 0:03
I'd prefer:
sudo systemsetup -setremotelogin on
-
5
Turning Remote Login on or off requires Full Disk Access privileges
– Att RighJun 16, 2022 at 21:39
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:
- Apple: Use the systemsetup command-line utility on macOS Catalina 10.15
- Ask different: Is there command to grant Full Disk Access for specific application?
- Ask different: macOS: List apps authorized for full disk access
- 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.
- 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.
- It works on the Mac VM I set up with Quickemu to play around there before breaking my employers Mac accidentally.