6

Please know I am no sysadmin.

Yesterday I re-installed UBUNTU 12.04 LTS - running 3.2.0-33-generic-pae.

I have worked for hours trying to install vsftpd to no avail, and now find myself trying to configure sftp via the sshd, if that makes sense.

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

when I sudo /etc/init.d/ssh restart it starts the ssh, but why not the sshd?

Thank You, David

1 Answer 1

5

You can't have sshd running with a bad sshd_config. I don't know what's in that 20 byte sshd_config of yours, but it's broken. Probably best to just reinstall the default at this point.

I've recreated your problem here in a 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#

As you can see, sshd did not restart when I removed sshd_config. Now, here's something interesting:

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

So, a completely blank sshd_config is sufficient to get it started. I DO NOT RECOMMEND THAT YOU DO THIS, HOWEVER. Instead, let's purge openssh-server and reinstall it, to restore the ORIGINAL, default 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

As you can see, we now have sshd running again, and with our default (87 lines long) sshd_config file.

In the future, I would recommend making backups of any config files you're experimenting with - cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.bak or similar. :)

3
  • Thank You Jim, very big help with excellent comment. It worked. So now I am off to try to configure this for sftp. Probably be asking more questions but THANK YOU!
    – David
    Nov 20, 2012 at 1:36
  • 3
    @David can you mark this question as answered, please? :)
    – Jim Salter
    Nov 21, 2012 at 1:47
  • 8 years later it is still not marked as solved but the purge solved it for me. where as /etc/ssh/sshd_config was empty and i wasn't able to connect with nautilus over ssh/sftp from centos 8 to ubuntu 18.04. Now everything works as expected and i can configure sshd as usual. Dec 18, 2020 at 6:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .