How do I stop/start ssh? I've tried
/etc/init.d/ssh restart
sudo service ssh restart
sudo restart ssh
I get errors every time.
|
15.04 and newer:Use this command:
To restart the SSH server/daemon. Going forward with
|
|||||
|
Pre 15.04:It should be as simple as (tested on a fresh install with openssh-server)
As it leverages upstart, this is The Best Way™ to do it, rather than using /etc/init.d/ssh, (I would recommend If those commands don't work, you are probably either experiencing a bug or have tinkered too far with your system, in which case you at least know what the problem isn't. |
|||||
|
|
Command for restart
|
|||
|
|
|
Since Ubuntu 15.04, Canonical no longer ships upstart by default. The correct method for restarting the SSH service (or any other service) now is one of the two following commands:
|
|||||
|
|
First check to see if sshd is running using the following:
You should see something like:
If you do not see a line for If you do see that line, next run this:
This should print the process id of sshd, so in this case you should see:
If the contents of sshd.pid does not match the process id of the running instance of sshd then something has restarted it incorrectly. But whatever the details you find here should put you on the right track. Either it's crashing, being restarted incorrectly, or never being started in the first place. |
|||
|
|
|
I think that the Unknown instance error is because SSH is not running. Try:
To see if the SSH daemon is running or not, you should see something like:
In any case, just try any of these: |
||||
|
|