LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-20-2006, 10:33 AM   #1
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Rep: Reputation: 31
Unhappy Cannot ssh inside my network


Hi guys, I was using ssh to connect to a LAMP server downstairs and it was working fine until yesterday after I came back from lunch. I was told to use nmap to scan for open ports. I only see that port 80 is open. Can I use this port for ssh. I keep getting the error: "Conection refused" I'm sorry if I don't make any sense, I'm new to this thing, but I want to learn!!

Thanks...
 
Old 07-20-2006, 10:51 AM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
You probably could, but you'd have to go downstairs and modify the server configuration.

And since you have to go downstairs anyway to do that, you might as well just go down and open up port 22 on the servers firewall and make sure that sshd is running on the server.
 
Old 07-20-2006, 11:26 AM   #3
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Original Poster
Rep: Reputation: 31
Thanks valdez! But sorry to ask you, is there a command to open up port 22 on the servers firewall, meaning on the computer I'm trying to connect? I thought that was done by the network admin. I told to run this command: "ps -A | grep ssh" to see if ssh is running and I got no output from it, what should I do?

Thanks for your help
 
Old 07-20-2006, 11:34 AM   #4
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
On the server, the network admin has to type
Code:
iptables -A INPUT -i eth2 -p tcp --dport 22 -j ACCEPT
Change eth2 to whatever the servers network interface is. Does that server have an ssh server active (I would assume it does)? Do you have a login account on that machine? Are you outside the local network that maybe your IP address is blocked from using ssh? Your admin should be able to help you with all these things.

It looks like the network admin asked you to check your machine for already running ssh sessions, which it appears you don't have any. This just means you couldn't connect.

The only other possibility I can see is that YOUR firewall is blocking outbound access from your machine to port 22. But doubt that. Can you post the output of iptables -L (you probably have to use sudo or be root)?
 
Old 07-20-2006, 11:59 AM   #5
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Original Poster
Rep: Reputation: 31
Let me go downstair to get that output. Thanks.
 
Old 07-20-2006, 12:23 PM   #6
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Original Poster
Rep: Reputation: 31
Ok this is the output of: "iptables -L"
(after running: "iptables -A INPUT -i eth2 -p tcp --dport 22 -j ACCEPT")

Chain INPUT(policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh

Chain FOWARD(policy ACCEPT)
target prot opt source destination

Chain OUTPUT(policy ACCEPT)
target prot opt source destination

Thanks for the help, I will be back in 1 hour. Lunch time!
 
Old 07-20-2006, 03:03 PM   #7
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Rep: Reputation: 30
type this in as root:

# service sshd start

Then try to connect.
 
Old 07-20-2006, 03:49 PM   #8
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Original Poster
Rep: Reputation: 31
I did a "sudo /etc/init.d/ssh restart"
Isn't this the same?? I'm going downstairs to try anyways.

Thanks, I will let you know in a momemt what happen.
 
Old 07-20-2006, 04:17 PM   #9
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Original Poster
Rep: Reputation: 31
NO, no results. When I typed the command "service sshd start" I get:
bash: service command not found.
I tried sshd start and I get: "sshd re-exec requires execution with an absolute path"

What else can I try?? help me please, I'm going nuts!
 
Old 07-20-2006, 05:34 PM   #10
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
maybe which sshd
then use the full path
 
Old 07-20-2006, 05:41 PM   #11
iamwilliam
Member
 
Registered: Apr 2006
Location: Nairobi
Distribution: CentOS
Posts: 78

Rep: Reputation: 21
Quote:
(after running: "iptables -A INPUT -i eth2 -p tcp --dport 22 -j ACCEPT")
is your server using the interface eth2.

try scan(nmap) the server again after "/etc/init.d/sshd start" on the server
 
Old 07-21-2006, 09:42 AM   #12
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Original Poster
Rep: Reputation: 31
The server is using interface eth0. I saw downstairs the the server is connected to a router. Could this be the problem? It was working fine 2 days ago.
 
Old 07-21-2006, 09:51 AM   #13
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Rep: Reputation: 30
Quote:
Originally Posted by cucolin@
NO, no results. When I typed the command "service sshd start" I get:
bash: service command not found.
I tried sshd start and I get: "sshd re-exec requires execution with an absolute path"

What else can I try?? help me please, I'm going nuts!

Then they as root:

# services sshd start

I dont remember whether there was an 's' at the end of that command or not. But try that. If you get an error message something in regards that you cant find "services" command probably your paths arent set up. Then do a search for it as follows as root to find that command:

# cd /
# find . -name services -print

Wait until it finishes...once found ... lets say its in "/usr/bin/services". Then use full path to start sshd daemon as follows:

# /usr/bin/services sshd start

If you get an error saying that process cant be started use this command to see if its already running:

# ps -eaf | grep -i sshd

if the process isnt running then use that services command to start it up. If all else fails check to see if your ssh package is installed usually they come preinstalled with operating system but in your case just double check. Use the following command:

# rpm -aq |grep -i ssh

If its not installed install it using yum as follows:

# yum install ssh

Say yes to all dependencies. Once you confirm that ssh is installed and is running as a daemon try connecting to it again using a "non-root" account. Because some systems block root access using ssh. So from your remote machine connecting to this machine on your remote machine you will type this as follows:

$ ssh ip_address -l username

Make sure you type ip address instead of host name because I dont know if you have DNS setup in /etc/hosts file. If you still cant connect then run this command for temporary purpose to disable your iptables firewall because I dont know if you have it configured correctly. This is done for testing purposes only. Use the services command as follows as root:

# services iptables stop

Once iptables are stopped try connecting from remote machine again. Again double check to make sure "sshd" daemon (process) is running using the ps command before you attempt remote connection. Also before connecting to your remote machine make sure you are connecting to that machine with the same username and password as when you log into it locally. So if you are using the following username to connect locally

username: John
password: smith

then using ssh command you would connect to that machine with those cridentials as follows:

$ ssh ip_address -l John
enter password: smith

Anyway try those troubleshooting steps and post again if you run into problems. Post with exact errors.

Cheers and good luck!
 
Old 07-21-2006, 10:38 AM   #14
cucolin@
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu, CentOS, RedHat
Posts: 416

Original Poster
Rep: Reputation: 31
Before I do that I wanted to show you the output of the
"sudo netstat -plant | LISTEN" command:

tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 5279/mysqld

tcp6 0 0 :::80 :::* LISTEN 10057/apache2

This might help solve the mistery. What does this means??
 
Old 07-21-2006, 10:52 AM   #15
iamwilliam
Member
 
Registered: Apr 2006
Location: Nairobi
Distribution: CentOS
Posts: 78

Rep: Reputation: 21
this confirms that the ssh port is not open. only mysqld(3306) and http(80) are running on the server. You need to start sshd

"/etc/init.d/sshd start"

on the server and check using the same command whether (22) is listening. Let me know how this
goes.
 
  


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
remote desktop,vnc,ssh inside a lan durden2.0 Linux - Networking 3 09-22-2006 04:55 PM
running samba inside ssh server kpachopoulos Linux - Networking 4 10-24-2004 04:12 PM
Can't ping inside network samus8zero2x Linux - Networking 11 09-21-2004 11:18 AM
[ Real NooB Inside ] VNC SSH - How to configure it ?? Slammy Linux - Networking 5 09-26-2003 01:17 PM
How to setting ipchains to let inside can using the SSH only, outside can't? explorer1979 Linux - Security 5 12-21-2002 05:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:46 PM.

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