LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-10-2012, 03:49 PM   #1
debq
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Rep: Reputation: Disabled
Can't connect to SSH server, port 22 refused...


So I have a CentOS server running on a dedicated machine. I downloaded the opens-server and -clients packages. I can start the server, but cannot connect to it from my laptop. When I attempt to connect from my Mac, the error says it can't connect to port 22.

So I can't really think of anything I did wrong...When I run "/sbin/service sshd status" I get
Code:
/etc/init.d/sshd: line 33 : /etc/sysconfig/sshd: Permission denied
openssh-daemon (pid 3265) is running...
I really hope you guys can help me with this, I've been struggling with it for a while. If anyone needs more information to help debug the problem just lemme know. Just a heads up: I'm a Linux newb, still getting used to everything. Thanks
 
Old 08-10-2012, 04:40 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
You need to open port 22 on the firewall.

Last edited by macemoneta; 08-10-2012 at 04:44 PM. Reason: Added link
 
Old 08-10-2012, 05:09 PM   #3
debq
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by macemoneta View Post
Just tried this... Didn't seem to do the trick. Restarted sshd and also tried opening both port 22s, still no luck.
 
Old 08-10-2012, 05:39 PM   #4
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Did you remember to apply the change and reload the firewall?
 
Old 08-10-2012, 05:50 PM   #5
debq
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by macemoneta View Post
Did you remember to apply the change and reload the firewall?
Nope, but I tried it again. Still no luck.
 
Old 08-10-2012, 05:57 PM   #6
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
If the server is running on port 22, and the firewall is open, then you should have access on the LAN. If you are still unable to access then either one or the other of these two is not true, or you are trying to connect to the wrong host.
 
Old 08-10-2012, 06:23 PM   #7
debq
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by macemoneta View Post
If the server is running on port 22, and the firewall is open, then you should have access on the LAN. If you are still unable to access then either one or the other of these two is not true, or you are trying to connect to the wrong host.
Pretty sure it should be working. The only criteria I would maybe question is if it's running on port 22. But I figure it has to be since it should run on that by default, from what I understand. I'm all out of ideas at this point.
 
Old 08-10-2012, 08:11 PM   #8
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Rep: Reputation: 34
Please show the out put of the
Code:
#netstat -natup
also 'cut and paste' the complete ( it should show the username on the system) command from client side your are invoking. Please show the error message as well.
 
Old 08-10-2012, 10:35 PM   #9
debq
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by KinnowGrower View Post
Please show the out put of the
Code:
#netstat -natup
also 'cut and paste' the complete ( it should show the username on the system) command from client side your are invoking. Please show the error message as well.
Output of command:
Code:
[root@Joe ~]# netstat -natup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1734/rpcbind        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2126/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1975/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      2206/master         
tcp        0      0 0.0.0.0:34947               0.0.0.0:*                   LISTEN      1905/rpc.statd      
tcp        0      0 192.168.1.10:35786          23.66.230.218:80            ESTABLISHED 2531/clock-applet   
tcp        0      0 :::111                      :::*                        LISTEN      1734/rpcbind        
tcp        0      0 :::22                       :::*                        LISTEN      2126/sshd           
tcp        0      0 ::1:631                     :::*                        LISTEN      1975/cupsd          
tcp        0      0 :::39837                    :::*                        LISTEN      1905/rpc.statd      
udp        0      0 0.0.0.0:5353                0.0.0.0:*                               1887/avahi-daemon   
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1734/rpcbind        
udp        0      0 0.0.0.0:43888               0.0.0.0:*                               1887/avahi-daemon   
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1975/cupsd          
udp        0      0 0.0.0.0:57211               0.0.0.0:*                               1905/rpc.statd      
udp        0      0 0.0.0.0:637                 0.0.0.0:*                               1734/rpcbind        
udp        0      0 0.0.0.0:809                 0.0.0.0:*                               1905/rpc.statd      
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               2595/dhclient       
udp        0      0 :::36330                    :::*                                    1905/rpc.statd      
udp        0      0 :::111                      :::*                                    1734/rpcbind        
udp        0      0 :::637                      :::*                                    1734/rpcbind        
[root@Joe ~]#
This is the command I invoke on the client to connect to the server:
Code:
new-host:~ joe$  ssh root@173.85.114.242
ssh: connect to host 173.85.114.242 port 22: Connection refused
I've tried connecting as root and as the primary user account, both don't work.
Hope that's what you were looking for.

Last edited by debq; 08-10-2012 at 10:49 PM.
 
Old 08-11-2012, 03:09 AM   #10
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Root should be refused by default, unless you've changed that in the configuration. Port 22 is listening, so sshd is running. The problem is likely in your firewall configuration. Try running the configuration tool and hit 'disable' to stop the firewall. With the firewall down, try to ssh (as a user, not root).
 
Old 08-11-2012, 07:54 AM   #11
debq
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by macemoneta View Post
Root should be refused by default, unless you've changed that in the configuration. Port 22 is listening, so sshd is running. The problem is likely in your firewall configuration. Try running the configuration tool and hit 'disable' to stop the firewall. With the firewall down, try to ssh (as a user, not root).
Disabled firewall, applied, still get
Code:
:~ joe$  ssh Joe@173.85.114.242
ssh: connect to host 173.85.114.242 port 22: Connection refused
If I try connecting with a two word username(which does not exist on the server), I get
Code:
:~ joe$  ssh Joe k@173.85.114.242
ssh: Could not resolve hostname Joe: nodename nor servname provided, or not known
It probably means nothing. But it's the only result I've ever gotten besides "Connection refused".

My next guess is maybe it has something to do with my router? Maybe forward ports or something? If the machine is running like its supposed to thats the only thing I can think of.
 
Old 08-11-2012, 08:07 AM   #12
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Your router only comes into play if you are trying to access the host from the Internet.
 
Old 08-11-2012, 10:46 AM   #13
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Rep: Reputation: 34
Can you please paste output of the command (run on ssh server) ?
Code:
ip addr
Also try ssh using private IP if possible.

Also you can do the following to troubleshoot
When you are running ssh command at client. Before that run the command at ssh server and watch for errors
Code:
#tail -f /var/log/auth.log

It will give you info what is happening at server side

Last edited by KinnowGrower; 08-11-2012 at 11:05 AM. Reason: added tip for tail command
 
Old 08-11-2012, 02:06 PM   #14
debq
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by KinnowGrower View Post
Can you please paste output of the command (run on ssh server) ?
Code:
ip addr
Also try ssh using private IP if possible.

Also you can do the following to troubleshoot
When you are running ssh command at client. Before that run the command at ssh server and watch for errors
Code:
#tail -f /var/log/auth.log

It will give you info what is happening at server side
Ok so I've been trying to connect to my public IP. Stupidly enough, I just now tried my private IP and it finally connected. Though how would I go about connecting when I'm not on my LAN network?
 
Old 08-11-2012, 03:14 PM   #15
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Rep: Reputation: 34
Either connect to the server at private LAN IP, using vpn or Public IP, and it should work.
 
  


Reply


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
[SOLVED] ssh: connect to host localhost port 22: Connection refused hussainv1 Linux - Desktop 6 05-30-2013 05:30 PM
ssh: connect to host 10.137.216.170 port 22: Connection refused bijaya.kumar Linux - Networking 5 02-14-2012 04:39 PM
ssh:connect to host restart port 22: Connection refused myubuntu Linux - Software 20 02-22-2010 11:32 PM
iptables help! DROP ssh port, but allow to connect to ssh if from 2222 port kandzha Linux - Networking 4 09-13-2006 09:10 AM
ssh refused to connect paulmedic555 Linux - Networking 2 11-01-2004 12:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:55 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