ssh on mac is disabled by default, that is, remote devices cannot connect to this machine through ssh.
Check the open status of ssh
sudo systemsetup -getremotelogin
If the command returns Remote Login: On
, it means that it has been opened, otherwise, it means that ssh has not been opened.
open ssh
You can open ssh with the following command to allow other devices to connect to the machine via ssh
sudo systemsetup -setremotelogin on
close ssh
ssh can be turned off by the following command to prohibit other devices from connecting to this machine through ssh
sudo systemsetup -setremotelogin off