So i've just started playing around with Ubuntu on Amazon EC2.

I've just issued the following command to restart ssh but it has now "killed" ssh.

sudo /etc/init.d/ssh restart

I can't seem to ssh to this instance anymore. Putty just gives me "connection refused".

NOTE: In this case I just restarted SSH to see the result. I didn't change any settings. This was to confirm that it was the restart command was the problem and not any configs I made.

What is the correct way to restart SSH? P.S. That usually works on other Ubuntu boxes.


EDIT: It is also worth noting that when I ran that command I was taken straight back to a prompt. I didn't get any output on the console.

  • 1
    You'll need to look at the logs. Can you restart the box without losing the log files? You should also edit the title of the question, as there's obviously no 12.10 version for Ubuntu, but there's an 11.10 and a 12.04. – cjc Jun 4 '12 at 16:33
  • Sorry guys, that was a badly composed question. Also, there was nothing in the logs. – jim Jun 4 '12 at 17:28

To solve this I just needed to

sudo apt-get install ssh

Then the command

sudo /etc/init.d/ssh restart

worked like a charm

  • 1
    In which case, you must have either made some config changes, or uninstalled ssh rather than restarted it. I'm not sure this answers your question which was 'What is the correct way to restart SSH'. – EightBitTony Jun 4 '12 at 18:06

In Ubuntu 12.04 you would usually do:

andersx@soprano:~$ sudo service ssh restart
ssh stop/waiting
ssh start/running, process 6104

The old fashioned way suggested by Conor H results in:

andersx@soprano:~$ sudo /etc/init.d/ssh restart
[sudo] password for andersx: 
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service ssh restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop ssh ; start ssh. The restart(8) utility is also available.
ssh start/running, process 6096

Alternatively you could do:

sudo restart ssh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.