3

On Mac, how to start/enable the sshd service?

I use network general tool to scan the ports, do not find the 22 port.

enter image description here

Seems Apple disables it by default.

I tried to open the sshd service:

aircraftdeMacBook-Pro:.ssh ldl$ sudo /usr/sbin/sshd
Password:
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_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.

But failed.

How to open sshd service on Mac?


EDIT

I also tried use ssh-keygen to generate secretkey, but still not work.

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
/usr/sbin/sshd
bmike
  • 235,889
aircraft
  • 1,775

1 Answers1

4

Turn on Remote Login under System Preferences >> Sharing

It will enable the sshd service and allow you to connect.

enter image description here

Allan
  • 101,432