Mac – Unable to restart ssh on Mac OS Sierra – launchctl unload Could not find specified service

macport-forwardingssh

I am trying to tunnel into a remote EC2 bastion server via ssh because I need to connect to a DB behind a firewall.

In the document linked above, in section Remote port forwarding, it says

There is one more thing you need to do to enable this. SSH doesn’t by
default allow remote hosts to forwarded ports. To enable this open
/etc/ssh/sshd_config and add the following line somewhere in that
config file.

So I changed GatewayPorts no ===> GatewayPorts yes and attempted to restart SSH as it stated. It recommends sudo service ssh restart, but I'm on Mac OS Sierra.

This SO Post says I can start/stop ssh via

sudo launchctl unload (or load) /System/Library/LaunchDaemons/ssh.plist

but get error

/System/Library/LaunchDaemons/ssh.plist: Could not find specified
service

Things I've tried:

  • This article says LaunchAgents is run as a user, not root, which I am doing.
  • /System/Library/LaunchDaemons/ssh.plist exists
  • launchctl has subcommand load and unload

So what's the problem?

Best Answer

You can restart openSSH on your mac with the following (tested on Sierra 10.12.6)

sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd

Source

Related Question