Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
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. –  Conor H Jun 4 '12 at 17:28
add comment

2 Answers

up vote 0 down vote accepted

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

share|improve this answer
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
add comment

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
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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