Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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!

share|improve this question
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
add comment

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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