12.04 sshd_config文件为空,但我的ssh_config不为空

Dav*_*vid 5 sshd

请知道我不是系统管理员。

昨天我重新安装了 UBUNTU 12.04 LTS - 运行 3.2.0-33-generic-pae。

我已经工作了几个小时试图安装 vsftpd 无济于事,现在发现自己试图通过 sshd 配置 sftp,如果这有意义的话。

ps -ef |grep ssh
00:00:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntu
NOTICE THE SIZE of my sshd_config
ls -la /etc/ssh/

-rw-r--r-- 1 root root 125749 Apr  2  2012 moduli
-rw-r--r-- 1 root root   1669 Nov 18 11:58 ssh_config
-rw-r--r-- 1 root root   1668 Nov 18 11:47 ssh_config~
-rw-r--r-- 1 root root     20 Nov 18 11:25 sshd_config
-rw------- 1 root root    672 Nov 18 11:29 ssh_host_dsa_key
-rw-r--r-- 1 root root    598 Nov 18 11:29 ssh_host_dsa_key.pub
-rw------- 1 root root    227 Nov 18 11:29 ssh_host_ecdsa_key
-rw-r--r-- 1 root root    170 Nov 18 11:29 ssh_host_ecdsa_key.pub
-rw------- 1 root root    973 Nov 18 11:29 ssh_host_key
-rw-r--r-- 1 root root    638 Nov 18 11:29 ssh_host_key.pub
-rw------- 1 root root   1675 Nov 18 11:29 ssh_host_rsa_key
-rw-r--r-- 1 root root    390 Nov 18 11:29 ssh_host_rsa_key.pub
-rw-r--r-- 1 root root    302 Jan 10  2011 ssh_import_id
Run Code Online (Sandbox Code Playgroud)

当我 sudo /etc/init.d/ssh restart 它会启动 ssh,但为什么不启动 sshd?

谢谢你,大卫

Jim*_*ter 5

您不能让 sshd 使用错误的 sshd_config 运行。我不知道你的 20 字节 sshd_config 中有什么,但它坏了。此时最好重新安装默认值。

我在 VM 中重新创建了您的问题:

root@ubusrv:/etc/ssh# ps wwaux | grep ssh | grep -v grep
root    1277   0.0  1.1   49948   2812 ?       Ss  15:33  0:00 /usr/sbin/sshd -D
root@ubusrv:/etc/ssh# rm sshd_config ; /etc/init.d/ssh restart ; ps wwaux | grep ssh | grep -v grep
root@ubusrv:/etc/ssh#
Run Code Online (Sandbox Code Playgroud)

如您所见,当我删除 sshd_config 时,sshd 没有重新启动。现在,这里有一些有趣的事情:

root@ubusrv:/etc/ssh# echo > sshd_config ; /etc/init.d/ssh start ; ps wwaux | grep ssh | grep -v grep
root    1364   0.0  1.1   49948   2804 ?       Ss  15:37  0:00 /usr/sbin/sshd -D
Run Code Online (Sandbox Code Playgroud)

因此,一个完全空白的sshd_config 足以启动它。但是,我不建议您这样做。相反,让我们清除 openssh-server 并重新安装它,以恢复原始的默认 sshd_config:

root@ubusrv:/etc/ssh# apt-get purge openssh-server ; apt-get install openssh-server
root@ubusrv:/etc/ssh# ps wwaux | grep ssh | grep -v grep
root    1762   0.0  1.1   49948   2820 ?       Ss  15:39  0:00 /usr/sbin/sshd -D
root@ubusrv:/etc/ssh# wc -l sshd_config
87 sshd_config
Run Code Online (Sandbox Code Playgroud)

如您所见,我们现在再次运行 sshd,并使用我们的默认(87 行)sshd_config 文件。

将来,我建议您备份您正在试验的任何配置文件 -cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.bak或类似文件。:)

  • @David 你能将此问题标记为已回答吗?:) (3认同)