10

I recently got Ubuntu 12.04 Precise, got it up and running with some MediaWiki software, static IP on the box and router and was able to access the main page even from a cell phone. Everything seemed great...

Then I wanted to finally get rid of the monitor and keyboard and login remotely via SSH.

I installed openssh-server, let everything point to port 22 for a test run and installed putty on my Windows XP machine. I got a connection refused. Went back and started checking the Ubuntu install itself... (I'm under root from this point on)

$ sudo -s

$ service ssh status
ssh stop/waiting

$ service ssh start
ssh start/running, process 2212

$ service ssh status
ssh stop/waiting

Apparently ssh has stopped or is waiting for something....

$ ssh localhost
ssh: connect to host localhost port 22: Connection refused

I can't even connect to myself... I checked ufw (firewall) to see if port 22 is doing alright...

$ sudo ufw status
Status: active
To        Action        From
22        ALLOW         Anywhere
22/tcp    ALLOW         Anywhere
22        ALLOW         Anywhere (v6)
22/tcp    ALLOW         Anywhere (v6)

sshd_config shows only Port 22

Is ssh not using the right IP address at all? I just don't get what I did wrong here. When this is up and running I will def change the port number, but for now, I don't want to mess with the default install too much until a test run with putty is successful.

Edit:

Here are my sshd_config file and my ssh_config file.

The command /usr/sbin/sshd -p 22 -D -d -e returns:

/etc/ssh/sshd_config line 159: Subsystem 'sftp' already defined.

Edit: @phoibus moving the sshd_config file and reinstalling did the trick!

service ssh status

the above command shows that ssh is now running and I am now able to log in from my windows xp computer remotely via putty. Thanks so much! I can now use my monitor for other things!

  • 1
    Can you post your ssh /etc/ssh/ssh_config on pastebin (paste.ubuntu.com) and edit you question to contain the link? – con-f-use Oct 17 '12 at 8:37
  • Stop the sshd service and run the sshd in standalone debug mode: /usr/sbin/sshd -p 22 -D -d -e. Try connecting and see what happens. – phoibos Oct 17 '12 at 8:48
  • Glad that it worked! Please remove your answer since you posted the information in your post and accept my answer to mark the question as solved. – phoibos Oct 17 '12 at 10:49
  • if this is happening in all users, make sure you are following this doc help.ubuntu.com/community/SSH/OpenSSH/Configuring especially check this doc, the part about /etc/ssh/ssh_host_dsa_key in this doc askubuntu.com/questions/485777/…. – JimLohse Feb 7 '16 at 4:24
10

You got duplicate sections in your /etc/ssh/sshd_config file.

Rename your sshd_config file

sudo mv /etc/ssh/sshd_config /etc/ssh/sshd_config.old

and reinstall openssh-server to get the original file:

sudo apt-get install --reinstall openssh-server

See if it works now.

4

My issue was also a setting issue, but I couldn't figure out which of my changes was the problem. After digging a little you can run sshd -t and any sshd_config errors will be reported.

root@sh1:/etc/ssh# sshd -t /etc/ssh/sshd_config line 102: Directive 'UsePAM' is not allowed within a Match block

Which means 'Match blocks' settings need to be at the end of the sshd_config file.

  • my error is : missing privilege separation directory: /var/run/sshd what now? – davejal Nov 2 '16 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.