How do you run an SSH server on macOS?
4 Answers
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).
- 105
- 3
- 1,755
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.
- 982