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

3

2

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?

Growler

Posted 2017-10-03T16:49:14.050

Reputation: 141

If you need a fix now you can just reboot your mac. – Sirens – 2017-10-03T16:51:51.243

Answers

5

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

Sirens

Posted 2017-10-03T16:49:14.050

Reputation: 206

0

or your commands work, but you need to super user do them (and I'm on High Sierra):

    sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
    sudo launchctl load /System/Library/LaunchDaemons/ssh.plist

hunter3740

Posted 2017-10-03T16:49:14.050

Reputation: 41