LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   ssh: connection to host port: 22: Connection timed out lost connection (https://www.linuxquestions.org/questions/linux-server-73/ssh-connection-to-host-port-22-connection-timed-out-lost-connection-537110/)

cucolin@ 03-13-2007 11:53 AM

ssh: connection to host port: 22: Connection timed out lost connection
 
We have 2 linux boxes on 2 different floors. I'm able to transfer files from Box A to Box B, but not from box B to box A. When I try to transfer files from B to A I get:

ssh: connect to host 10.0.0.1 port 22: Connection timed out lost connection

What might be the problem here?? I'm able to ping from both machines: A to B and B to A with no errors.

Thanks

MensaWater 03-13-2007 12:23 PM

Could be:
a) You're not running sshd on Box A.
b) You're running a firewall somewhere that is blocking inbound port 22 to Box A.

On Box A run:
lsof -i :22

You should see (among other things) a line like the following showing it is LISTENing for connections. If not you may need to start your sshd or at least verify /etc/xinetd.d has it started.
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
sshd 1781 root 3u IPv6 4892 TCP *:ssh (LISTEN)

If above is running you can try "telnet <box a> 22" to see if this times out as well. If so it would indicate something isn't allowing connections even though you're LISTENing for them.

Possible culprits:
iptables (or some other firewall software) on Box A. If iptables you can run "service iptables stop" then test it. If it works you know it was iptables. You'd then need to figure out a rule to allow port 22 from Box B OR leave iptables off. (You should make a rule. Command to restart iptables is "service iptables start". Turn it off just to see if it is the problem.)

SELinux on Box A. SELinux is a new NSA sponsored security sort of like a firewall on steroids and it is a huge pain for most people. Most people just disable it.

A physical switch/firewall between Box A and Box B that prevents port 22 traffic to Box A. For this you'd have to get a Network person involved if you're not the one who administers these. Typically between floors in buildings there are "VLANS" that do this kind of blocking.

cucolin@ 03-13-2007 02:54 PM

jlighter, thanks a lot!! It seems that most of the greatest problems are caused by a stupid/simple mistake. I forgot I have installed firestarter firewall on box A and it was blocking port 22. Thanks a lot, I don't know why I didn't check for that first. Is firestarter configurable by the command line also? I had to go to box A and allow port 22 using the GUI.

Thanks

MensaWater 03-13-2007 03:14 PM

I haven't used Firestarter but I gather from other comments I've seen that it is just a GUI front end for iptables. Since you can configure iptables from command line the answer would be yes.

"iptables -L" will list your current rules from command line.

In UNIX/Linux almost everything can be done from the command line even if it is sometimes easier to do from GUI. (Some GUI utilities even have logging modes that will show you the command line they're running behind the scenes.) This is mainly to allow for scripting tasks. I've been doing UNIX for so long it often doesn't even occur to me to look for a GUI solution even on the systems where I have KDE or Gnome running.

dep 11-22-2011 06:15 AM

I've got this problem too. Ping works, but no connections can be made.

Quote:

Originally Posted by MensaWater (Post 2668492)
a) You're not running sshd on Box A.

I double-checked, then ran it with the -d switch to observe the output. Nothing happens when I try to connect from a remote machine. I can ssh from localhost, however!

Quote:

Originally Posted by MensaWater (Post 2668492)
b) You're running a firewall somewhere that is blocking inbound port 22 to Box A.

My network topology is such that box A and box B are separated only by a wireless router, where the iptables rules are set to allow all within the LAN:
Code:

#PORT FORWARDS
iptables -I FORWARD -d 192.168.1.129 -j ACCEPT
iptables -I FORWARD -d 192.168.1.121 -j ACCEPT

Quote:

Originally Posted by MensaWater (Post 2668492)
On Box A run:
lsof -i :22

Shows nothing (unless I'm locally connected to an SSH session; however,
Code:

netstat -ntl |grep :22
shows tcp and tcp6 LISTENing status for the local IP of box A:
Quote:

tcp 0 0 192.168.1.129:22 0.0.0.0:* LISTEN
Quote:

Originally Posted by MensaWater (Post 2668492)
If above is running you can try "telnet <box a> 22" to see if this times out as well.

It does.

Quote:

Originally Posted by MensaWater (Post 2668492)
Possible culprits:
iptables (or some other firewall software) on Box A.

No firewall running on box A - iptables yes this was it - see http://serverfault.com/questions/197...ion-timed-out:
Quote:

Chain INPUT (policy DROP)
target prot opt source destination
ufw-before-logging-input all -- anywhere anywhere
ufw-before-input all -- anywhere anywhere
ufw-after-input all -- anywhere anywhere
ufw-after-logging-input all -- anywhere anywhere
ufw-reject-input all -- anywhere anywhere
ufw-track-input all -- anywhere anywhere

Chain FORWARD (policy DROP)
target prot opt source destination
ufw-before-logging-forward all -- anywhere anywhere
ufw-before-forward all -- anywhere anywhere
ufw-after-forward all -- anywhere anywhere
ufw-after-logging-forward all -- anywhere anywhere
ufw-reject-forward all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ufw-before-logging-output all -- anywhere anywhere
ufw-before-output all -- anywhere anywhere
ufw-after-output all -- anywhere anywhere
ufw-after-logging-output all -- anywhere anywhere
ufw-reject-output all -- anywhere anywhere
ufw-track-output all -- anywhere anywhere

Chain ufw-after-forward (1 references)
target prot opt source destination

Chain ufw-after-input (1 references)
target prot opt source destination
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:netbios-ns
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:netbios-dgm
ufw-skip-to-policy-input tcp -- anywhere anywhere tcp dpt:netbios-ssn
ufw-skip-to-policy-input tcp -- anywhere anywhere tcp dpt:microsoft-ds
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:bootps
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:bootpc
ufw-skip-to-policy-input all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST

Chain ufw-after-logging-forward (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK] '

Chain ufw-after-logging-input (1 references)
target prot opt source destination

Chain ufw-after-logging-output (1 references)
target prot opt source destination

Chain ufw-after-output (1 references)
target prot opt source destination

Chain ufw-before-forward (1 references)
target prot opt source destination
ufw-user-forward all -- anywhere anywhere

Chain ufw-before-input (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ufw-logging-deny all -- anywhere anywhere state INVALID
DROP all -- anywhere anywhere state INVALID
ACCEPT icmp -- anywhere anywhere icmp destination-unreachable
ACCEPT icmp -- anywhere anywhere icmp source-quench
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-problem
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
ufw-not-local all -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere 239.255.255.250 udp dpt:1900
ufw-user-input all -- anywhere anywhere

Chain ufw-before-logging-forward (1 references)
target prot opt source destination

Chain ufw-before-logging-input (1 references)
target prot opt source destination

Chain ufw-before-logging-output (1 references)
target prot opt source destination

Chain ufw-before-output (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ufw-user-output all -- anywhere anywhere

Chain ufw-logging-allow (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW ALLOW] '

Chain ufw-logging-deny (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere state INVALID limit: avg 3/min burst 10
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK] '

Chain ufw-not-local (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
RETURN all -- anywhere anywhere ADDRTYPE match dst-type MULTICAST
RETURN all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
ufw-logging-deny all -- anywhere anywhere limit: avg 3/min burst 10
DROP all -- anywhere anywhere

Chain ufw-reject-forward (1 references)
target prot opt source destination

Chain ufw-reject-input (1 references)
target prot opt source destination

Chain ufw-reject-output (1 references)
target prot opt source destination

Chain ufw-skip-to-policy-forward (0 references)
target prot opt source destination
DROP all -- anywhere anywhere

Chain ufw-skip-to-policy-input (7 references)
target prot opt source destination
DROP all -- anywhere anywhere

Chain ufw-skip-to-policy-output (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere

Chain ufw-track-input (1 references)
target prot opt source destination

Chain ufw-track-output (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere state NEW
ACCEPT udp -- anywhere anywhere state NEW

Chain ufw-user-forward (1 references)
target prot opt source destination

Chain ufw-user-input (1 references)
target prot opt source destination

Chain ufw-user-limit (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 5 LOG level warning prefix `[UFW LIMIT BLOCK] '
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable

Chain ufw-user-limit-accept (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere

Chain ufw-user-logging-forward (0 references)
target prot opt source destination

Chain ufw-user-logging-input (0 references)
target prot opt source destination

Chain ufw-user-logging-output (0 references)
target prot opt source destination

Chain ufw-user-output (1 references)
target prot opt source destination
Quote:

Originally Posted by MensaWater (Post 2668492)
If iptables you can run "service iptables stop" then test it.

Strangely, iptables was not recognized by the services command.

Quote:

Originally Posted by MensaWater (Post 2668492)
SELinux on Box A.

Nope, Ubuntu 11.10. For the record, this (among other things) worked perfectly alright before the upgrade to Oneiric.

Quote:

Originally Posted by MensaWater (Post 2668492)
A physical switch/firewall between Box A and Box B that prevents port 22 traffic to Box A.

There's a router running dd-wrt in between (as I said, set not to block anything), but with syslogd not logging anything when I try to connect, how can I investigate this further?


All times are GMT -5. The time now is 08:38 AM.