Ubuntu

無法在 Ubuntu 12.04 AWS EC2 上啟動 SSH

  • February 23, 2013

所以我剛剛開始在 Amazon EC2 上使用 Ubuntu。

我剛剛發出了以下命令來重新啟動 ssh,但它現在已經“殺死”了 ssh。

sudo /etc/init.d/ssh restart

我似乎無法再 ssh 到這個實例了。膩子只是給我“連接被拒絕”。

注意:在這種情況下,我只是重新啟動 SSH 以查看結果。我沒有更改任何設置。這是為了確認問題是重啟命令而不是我所做的任何配置。

重啟SSH的正確方法是什麼?PS 這通常適用於其他 Ubuntu 機器。

謝謝。

編輯:還值得注意的是,當我執行該命令時,我被直接帶回提示符。我在控制台上沒有得到任何輸出。

為了解決這個問題,我只需要

sudo apt-get install ssh

然後命令

sudo /etc/init.d/ssh restart

像魅力一樣工作

在 Ubuntu 12.04 中,您通常會這樣做:

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

Conor H 建議的老式方法導致:

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
andersx@soprano:~$

或者你可以這樣做:

sudo restart ssh

引用自:https://serverfault.com/questions/395421