如何禁用 SSHD 自动启动?

kom*_*tes 33 sshd

安装 openssh-server 后,每次启动时服务器都会启动。如果我希望它是手动的,我需要做什么?

在 upstart 的 0.6.7+ 版本中,我会在作业文件中添加一个“手动”节。

10.04 有新贵 0.6.5-8。在这种情况下,禁用 ssh 自动启动的首选方法是什么?

kom*_*tes 32

将 /etc/init/ssh.conf 重命名为 /etc/init/ssh.conf.disabled。

sudo mv /etc/init/ssh.conf /etc/init/ssh.conf.disabled
Run Code Online (Sandbox Code Playgroud)

  • 可能比 `echo 手册 | 更好 sudo tee /etc/init/ssh.conf.override` ,另请参阅[如何启用或禁用服务](http://askubuntu.com/questions/19320/how-to-enable-or-禁用服务) (2认同)

hhl*_*hlp 21

这应该足够了,:

 update-rc.d ssh enable # sets the default runlevels to on 
 update-rc.d ssh disable # sets all to off
Run Code Online (Sandbox Code Playgroud)


Bry*_*gee 9

在您的 /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
Run Code Online (Sandbox Code Playgroud)


Joc*_*lyn 8

对于具有systemd正确方法的系统是

sudo systemctl disable ssh.service
Run Code Online (Sandbox Code Playgroud)

然后

sudo systemctl stop ssh.service
Run Code Online (Sandbox Code Playgroud)


小智 7

读者注意:

对我(ubuntu 14.xx)来说,只有 Bryan Agee 的回答有效:/etc/init/ssh.conf: 注释掉“start on filesystem or runlevel...”行

为什么其他人不做?

须藤 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