21

How to restart SSH in Mac Pro?

When I used: sudo service ssh restart its shows:

Command not found

sudo service ssh restart, Command not found

kenorb
  • 24,736
  • 27
  • 129
  • 199
Aarthi Thala
  • 311
  • 1
  • 2
  • 3
  • 1
    This is a System V command that macOS does not have. What do you want to achieve, really? Are you experiencing any issues with SSH logins? – slhck Oct 01 '19 at 12:16
  • 1
    Furthermore, macOS manages `sshd` differently enough that there's no real equivalent to "restart"ing the service. More specifically, a new server process is started for each incoming connection on port 22; this means that if there's no active ssh connection, there's nothing running to restart (and if there is one, you probably don't want to kill it). So... yeah, what's the actual goal here? – Gordon Davisson Oct 01 '19 at 17:42

2 Answers2

14

Try with:

sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist 
alessiosavi
  • 408
  • 2
  • 9
  • what about `sudo /usr/sbin/sshd` in case it doesn't work? Also `sudo systemsetup -setremotelogin on` in case it is not open. – MeadowMuffins Jan 20 '21 at 13:46
11

Go to System Preferences > Sharing, uncheck Remote Login, recheck Remote Login.