如何禁止 SSHD 自動啟動?

如何禁止 SSHD 自動啟動?

安裝 openssh-server 後,每次啟動時伺服器都會啟動。如果我希望它是手動的,我需要做什麼?

在 upstart 的 0.6.7+ 版本中,我會在作業文件中新增一個「手動」節。

10.04有暴發戶0.6.5-8。在這種情況下,停用 ssh 自動啟動的首選方法是什麼?

答案1

將 /etc/init/ssh.conf 重新命名為 /etc/init/ssh.conf.disabled。

sudo mv /etc/init/ssh.conf /etc/init/ssh.conf.disabled

答案2

這應該夠了:

 update-rc.d ssh enable # sets the default runlevels to on 
 update-rc.d ssh disable # sets all to off

答案3

在 /etc/init/ssh.conf 中,註解掉開始線:

# ssh - OpenBSD Secure Shell server
#
# The OpenSSH server provides secure shell access to the system.

description     "OpenSSH server"

#start on filesystem or runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 10 5
umask 022

答案4

讀者須知:

對我來說(ubuntu 14.xx)只有 Bryan Agee 的答案有效: /etc/init/ssh.conf:註解「在檔案系統或運行層級上啟動...」行

為什麼其他人不這樣做?

sudo mv /etc/init/ssh.conf /etc/init/ssh.conf.disabled

將導致完全停用服務。然後它就無法再透過「service ssh start」啟動。

update-rc.d ssh enable # 將預設運行等級設定為 on

根本不起作用(可能使用不同的自動啟動例程)

/etc/init/ssh.conf.override 與“手動”

根本行不通

觸碰 /etc/ssh/sshd_not_to_be_run

也完全禁用系統

sudo apt-get install bum

不錯的軟體,但它不顯示 ssh,所以這裡沒什麼可做的

提問者:為什麼上面的答案還在這裡?啟動系統這麼複雜還是沒有人嘗試他的解決方案? oO

相關內容