ssh localhost
//ssh: connect to host localhost port 22: Connection refused

# 开启远程连接
sudo systemsetup -f -setremotelogin on

ssh localhost 
//ok

或者通过界面设置

系统偏好设置->共享->远程登录