LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Cannot ssh inside my network (https://www.linuxquestions.org/questions/linux-networking-3/cannot-ssh-inside-my-network-465901/)

cucolin@ 07-20-2006 09:33 AM

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...

pljvaldez 07-20-2006 09:51 AM

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.

cucolin@ 07-20-2006 10:26 AM

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

pljvaldez 07-20-2006 10:34 AM

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)?

cucolin@ 07-20-2006 10:59 AM

Let me go downstair to get that output. Thanks.

cucolin@ 07-20-2006 11:23 AM

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!

Xris718 07-20-2006 02:03 PM

type this in as root:

# service sshd start

Then try to connect.

cucolin@ 07-20-2006 02:49 PM

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.

cucolin@ 07-20-2006 03:17 PM

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!

Emmanuel_uk 07-20-2006 04:34 PM

maybe which sshd
then use the full path

iamwilliam 07-20-2006 04:41 PM

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

cucolin@ 07-21-2006 08:42 AM

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.

Xris718 07-21-2006 08:51 AM

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!

cucolin@ 07-21-2006 09:38 AM

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??

iamwilliam 07-21-2006 09:52 AM

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.


All times are GMT -5. The time now is 05:06 AM.