LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-19-2010, 11:09 PM   #1
myubuntu
LQ Newbie
 
Registered: Feb 2010
Posts: 23
Blog Entries: 2

Rep: Reputation: 15
Post ssh:connect to host restart port 22: Connection refused


Hi guys I am getting "ssh:connect to host restart port 22: Connection refused" error when trying to start "ssh" in Ubuntu. I uncommented the port 22 in ssh_config, I dont have iptables setup...Did try to check if the port is listening using the netstat -an | grep "LISTEN" & couldnt find. Any solutions pls......

VIJNB
 
Old 02-19-2010, 11:12 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by myubuntu View Post
Hi guys I am getting "ssh:connect to host restart port 22: Connection refused" error when trying to start "ssh" in Ubuntu. I uncommented the port 22 in ssh_config, I dont have iptables setup...Did try to check if the port is listening using the netstat -an | grep "LISTEN" & couldnt find. Any solutions pls......
It sounds like the SSH daemon is listening on another port. Check the sshd_config file on the remote box and see what port it's configured to listen on, then use netstat to verify it's doing so.

BTW, this thread will likely be moved to a more appropriate forum, as it's not a security issue (at least not directly).

Last edited by win32sux; 02-19-2010 at 11:16 PM.
 
Old 02-19-2010, 11:15 PM   #3
myubuntu
LQ Newbie
 
Registered: Feb 2010
Posts: 23

Original Poster
Blog Entries: 2

Rep: Reputation: 15
Post ssh:connect to host restart port 22: Connection refused

Hey thanks for your reply, checked the sshd_config, its also in port 22, any other solution
 
Old 02-19-2010, 11:17 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Do you have some other means of accessing the remote box? The objective being to make sure it's actually listening on that port, and that there are no interfering firewall rules. If the remote box sits behind a dedicated firewall, you'll want to check that too.

Last edited by win32sux; 02-19-2010 at 11:19 PM.
 
Old 02-19-2010, 11:21 PM   #5
myubuntu
LQ Newbie
 
Registered: Feb 2010
Posts: 23

Original Poster
Blog Entries: 2

Rep: Reputation: 15
No I dont have a remote box as I am trying this in stand alone Ubuntu & I did install the openssh-server, I am first trying to start the server.
 
Old 02-19-2010, 11:26 PM   #6
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by myubuntu View Post
No I dont have a remote box as I am trying this in stand alone Ubuntu & I did install the openssh-server, I am first trying to start the server.
Uh, ssh_config isn't the server configuration file (it's the client configuration file). What you're looking for instead is sshd_config. Also, right after installation it should have generated the key pair and started itself up. If you need to manually start it, the command would be:
Code:
sudo /etc/init.d/ssh start
If you just execute the ssh command directly, you're running the client, not the server.

Last edited by win32sux; 02-19-2010 at 11:27 PM.
 
Old 02-19-2010, 11:32 PM   #7
myubuntu
LQ Newbie
 
Registered: Feb 2010
Posts: 23

Original Poster
Blog Entries: 2

Rep: Reputation: 15
Yes I got the server started message, but when I tried to stop / start manually, it gave me the message, any clue??, I used the same code : sudo /etc/init.d/ssh start ....still getting the same error!!!!!
 
Old 02-19-2010, 11:38 PM   #8
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by myubuntu View Post
Yes I got the server started message, but when I tried to stop / start manually, it gave me the message, any clue??, I used the same code : sudo /etc/init.d/ssh start ....still getting the same error!!!!!
Something's not adding up here. The connection refused error message you posted looks like an SSH client error, not a server one. The server doesn't try to start a connection. What's the output of:
Code:
sudo netstat -pantu | grep LISTEN
 
Old 02-19-2010, 11:42 PM   #9
myubuntu
LQ Newbie
 
Registered: Feb 2010
Posts: 23

Original Poster
Blog Entries: 2

Rep: Reputation: 15
the output is

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 936/cupsd
tcp6 0 0 ::1:631 :::* LISTEN 936/cupsd
udp 0 0 0.0.0.0:68 0.0.0.0:* 979/dhclient
udp 0 0 0.0.0.0:5353 0.0.0.0:* 789/avahi-daemon: r
udp 0 0 0.0.0.0:47477 0.0.0.0:* 789/avahi-daemon: r
 
Old 02-19-2010, 11:45 PM   #10
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
What about the output of:
Code:
sudo /etc/init.d/ssh restart
 
Old 02-19-2010, 11:48 PM   #11
myubuntu
LQ Newbie
 
Registered: Feb 2010
Posts: 23

Original Poster
Blog Entries: 2

Rep: Reputation: 15
Quote:
Originally Posted by win32sux View Post
What about the output of:
Code:
sudo /etc/init.d/ssh restart
the same error - ssh:connect to host restart port 22: Connection refused
 
Old 02-19-2010, 11:51 PM   #12
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by myubuntu View Post
the same error - ssh:connect to host restart port 22: Connection refused
Weird, it's like the SSH daemon's startup script is acting like a client.

What about:
Code:
ls -l /etc/init.d/ssh
And:
Code:
head /etc/init.d/ssh
 
Old 02-19-2010, 11:56 PM   #13
myubuntu
LQ Newbie
 
Registered: Feb 2010
Posts: 23

Original Poster
Blog Entries: 2

Rep: Reputation: 15
Quote:
Originally Posted by win32sux View Post
Weird, it's like the SSH daemon's startup script is acting like a client.

What about:
Code:
ls -l /etc/init.d/ssh
And:
Code:
head /etc/init.d/ssh
>> the output is.....

root@mgroms:~# ls -l /etc/init.d/ssh
-rwxr-xr-x 1 root root 3878 2009-10-22 15:50 /etc/init.d/ssh
root@mgroms:~# head /etc/init.d/ssh
#! /bin/sh

### BEGIN INIT INFO
# Provides: sshd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: OpenBSD Secure Shell server
### END INIT INFO
 
Old 02-20-2010, 12:00 AM   #14
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
That looks sane. I'm not sure what to make of this. Since this is such an early stage, would you be willing to re-install the SSH daemon package? It would go like:
Code:
sudo apt-get remove --purge openssh-server
sudo apt-get install openssh-server
Like I said, after that last command it should be up and running without the need for you to edit anything.
 
1 members found this post helpful.
Old 02-20-2010, 12:18 AM   #15
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
FWIW, this is what the installation looks like on my Ubuntu 8.10 box:
Code:
win32sux@candystore:~$ sudo apt-get install openssh-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  rssh molly-guard openssh-blacklist openssh-blacklist-extra
The following NEW packages will be installed:
  openssh-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 285kB of archives.
After this operation, 782kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com intrepid/main openssh-server 1:5.1p1-3ubuntu1 [285kB]
Fetched 285kB in 2s (114kB/s)          
Preconfiguring packages ...
Selecting previously deselected package openssh-server.
(Reading database ... 213706 files and directories currently installed.)
Unpacking openssh-server (from .../openssh-server_1%3a5.1p1-3ubuntu1_i386.deb) ...
Processing triggers for ufw ...
Processing triggers for man-db ...
Setting up openssh-server (1:5.1p1-3ubuntu1) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
 * Restarting OpenBSD Secure Shell server sshd                                                                                                        [ OK ] 

win32sux@candystore:~$ sudo netstat -pantu | grep LISTEN | grep ssh
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      19719/sshd      
win32sux@candystore:~$ sudo /etc/init.d/ssh restart
 * Restarting OpenBSD Secure Shell server sshd                                                                                                        [ OK ] 
win32sux@candystore:~$

Last edited by win32sux; 02-20-2010 at 12:26 AM.
 
  


Reply

Tags
connection, host, port, refused, restart


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
curl: (7) couldn't connect to host // wget --> failed: Connection refused. linea Linux - Newbie 12 05-21-2012 01:56 PM
ssh: connect to host thyme1 port 22: Connection timed out - solved abstom Linux - Server 1 09-19-2009 06:33 AM
telnet: Unable to connect to remote host: Connection refused thomas2004ch Linux - Newbie 1 09-11-2009 03:51 AM
telnet: Unable to connect to remote host: Connection refused stuckz Fedora 6 06-21-2007 03:36 AM
telnet: Unable to connect to remote host: Connection refused stuckz Fedora - Installation 2 06-19-2007 10:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration