The server is running macOS Mojave 10.14.4. I'm unable to get the SSH daemon to start. After logging in locally, I run:

$ launchctl list | grep ssh
-   0   com.openssh.ssh-agent
$ ps -A | grep ssh 
1483 ??         0:00.00 ssh-agent -s
8483 ??         0:00.00 ssh-agent

The service is not active. To resolve this, I've tried:

$ sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
$ sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
$ sudo launchctl stop com.openssh.sshd 
$ sudo launchctl start com.openssh.sshd 
$ eval `ssh-agent -s`                                                                                  
Agent pid 9055

I'm not having any luck. The last thing I attempted before having to take a break from trying to solve this issue was:

$ /usr/sbin/sshd -d     
debug1: sshd version OpenSSH_7.9, LibreSSL 2.7.3
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.

I then ran $ ssh-keygen -A but still receive the same message.


For enabling the SSH service/daemon in MacOS do:

sudo systemsetup -setremotelogin on

For disabling the SSH service do:

sudo systemsetup -setremotelogin off

For checking whether it is on or off:

 sudo systemsetup -getremotelogin 

(Tested with Mojave)

Btw, sshd has to be run as root, not as you are running it. It has to be:

sudo /usr/sbin/sshd -d &
  • I have tried setremotelogin off then setremotelogin on but it's not effective – cryptic Apr 27 at 19:11
  • @cryptic Mojave here and working, what do you have? Was it too fast? How you tested? Using sudo? It has got to be as root. – Rui F Ribeiro Apr 27 at 19:35
  • I'm on Mojave as well. You're right, I didn't run sshd as root which is not right. SSH is working now but I think the problem was that a different version of OpenSSH was also installed via Homebrew and was conflicting with the system version in some way – cryptic Apr 27 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.