LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 06-29-2008, 09:04 PM   #1
bkorb
GNU Contributor
 
Registered: Sep 2006
Location: Sta. Cruz, CA
Distribution: openSUSE
Posts: 62

Rep: Reputation: 17
Question Connection refused on RemoteForward-ed port


It used to be the case that I could run:

ssh -v -q -g -R 3353:localhost:22 -n -o BatchMode=yes \
-o StrictHostKeyChecking=no <<my-home-machine>>

and from my home machine, I could simply:

ssh -X -p 3353 bkorb@localhost

and presto, I'm logged into my machine at work.
It worked until I upgraded my SuSE Linux 10.3 to 11.0.
I get the remote connection just fine:

$ ps -w -f -u <funny-user-name>
UID PID PPID C STIME TTY TIME CMD
1000 24894 24885 0 18:50 pts/1 00:00:00 sshd: remote-bk@notty
1000 24895 24894 97 18:50 ? 00:08:00 hold-open

(where "hold-open" is a special non-shell shell for "funny-user-name")
but trying to get back to the office is not working:

$ ssh -vvv -X -p <port> localhost
OpenSSH_5.0p1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /home/bkorb/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 3353.
debug1: connect to address 127.0.0.1 port 3353: Connection refused
debug1: Connecting to localhost [::1] port 3353.
debug1: connect to address ::1 port 3353: Connection refused
ssh: connect to host localhost port 3353: Connection refused

I have sshd running in debug mode, but it has no output while I do this.
Oh, and in /etc/ssh/sshd_config:

# egrep -v $'^[ \t]*($|#)' /etc/ssh/sshd_config
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
PermitRootLogin no
PasswordAuthentication no
ChallengeResponseAuthentication yes
AllowTcpForwarding yes
X11Forwarding yes
PermitTunnel yes
Subsystem sftp /usr/lib64/ssh/sftp-server
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL

I've been at this all afternoon. And evening now.
Any help would be most sincerely appreciated!!

Regards, Bruce
 
Old 06-29-2008, 09:43 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
GatewayPorts yes required in sshd_config ?
 
Old 06-29-2008, 10:02 PM   #3
bkorb
GNU Contributor
 
Registered: Sep 2006
Location: Sta. Cruz, CA
Distribution: openSUSE
Posts: 62

Original Poster
Rep: Reputation: 17
*Local* connection refused....

No, not required. My home machine is not acting as a gateway.
 
Old 06-29-2008, 10:39 PM   #4
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
Well the major change between previous versions of OpenSSH and the one you're using now is that it will refuse to allow X forwarding unless it can bind to the specified port for all address families, i.e. it needs to be able to bind to both IPv4 and IPv6. If one of them fails, it won't listen at all.

Have you checked to make sure you can actually bind to your given port for both versions of IP?

Have you tried lsof -i to see what ports are opened by what programs?
 
Old 06-30-2008, 09:48 AM   #5
bkorb
GNU Contributor
 
Registered: Sep 2006
Location: Sta. Cruz, CA
Distribution: openSUSE
Posts: 62

Original Poster
Rep: Reputation: 17
"lsof -i" yielded these two descriptors of interest:

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 3546 root 3r IPv4 10816 0t0 TCP 192.168.1.102:spr-itunes->{workmach}:spr-itunes (ESTABLISHED)
sshd 3548 remote-bk 3u IPv4 10816 0t0 TCP 192.168.1.102:spr-itunes->{workmach}:spr-itunes (ESTABLISHED)

(I removed firefox, ntpd, cupsd, portmap, master and avahi-daemon opens.)
I don't know anything about ipv4/6 needs. I just did a plain developer
install of openSuSE 11.0. I tried a more extensive install, but it choked and
died. Probably because /dev/null was a regular file. I didn't discover _that_
problem until after the re-re-install of 11.0. Really Tiresome.
Maybe I had better drop back to 10.3 and live with _its_ problems.
 
Old 06-30-2008, 02:55 PM   #6
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
So this is with the tunnel running, yes?

Seems like nothing has grabbed the port on an IPv6 address, so it should be OK...

If you telnet localhost 3353, what do you get?

Also, since that port is used by iTunes for sharing, have you tried using a different port? It's possible SuSE might have a special firewall rule to redirect that port...
 
Old 06-30-2008, 03:26 PM   #7
bkorb
GNU Contributor
 
Registered: Sep 2006
Location: Sta. Cruz, CA
Distribution: openSUSE
Posts: 62

Original Poster
Rep: Reputation: 17
Nothing helpful

$ telnet localhost 3353
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying ::1...
telnet: connect to address ::1: Connection refused

RE: port 3353 SuSE had better not be doing that. Leastwise,
they are surely not supposed to. Anyway, the same result
using 4353 anyway...

So, I've downloaded and built the sources for the latest ssh release.
Same result with that, too.
 
Old 06-30-2008, 05:05 PM   #8
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
Do you get anything in the logs on the remote server? Can you do a tcpdump on the remote server and see if there's even incoming traffic when you try to connect to the tunnel (or actually just tcpdump on your home machine and see if traffic goes out at all). If you don't see any traffic going to the IP address of your server at work, then it's the local connection that's being blocked, not the one on the other end.

Have you tried momentarily stopping iptables on your home machine to see if you can connect?
 
Old 06-30-2008, 05:33 PM   #9
bkorb
GNU Contributor
 
Registered: Sep 2006
Location: Sta. Cruz, CA
Distribution: openSUSE
Posts: 62

Original Poster
Rep: Reputation: 17
meaning /var/log/messages?

Jun 30 14:31:08 linux-rq7w sshd[17825]: Invalid user gt05 from 201.22.124.4
Jun 30 14:31:22 linux-rq7w sshd[17827]: reverse mapping checking getaddrinfo forlibraterminal4.static.gvt.net.br [201.22.124.4] failed - POSSIBLE BREAK-IN ATTEMPT!
Jun 30 14:31:22 linux-rq7w sshd[17827]: Invalid user william from 201.22.124.4
Jun 30 14:36:10 linux-rq7w syslog-ng[1812]: STATS: dropped 0
Jun 30 15:04:08 linux-rq7w sshd[18005]: Accepted publickey for remote-bk from 66.126.187.197 port 60606 ssh2
Jun 30 15:10:41 linux-rq7w sshd[18016]: Accepted publickey for remote-bk from 66.126.187.197 port 2347 ssh2
Jun 30 15:18:40 linux-rq7w sshd[18049]: Accepted publickey for remote-bk from 66.126.187.197 port 9704 ssh2
Jun 30 15:24:53 linux-rq7w kernel: device eth0 entered promiscuous mode
Jun 30 15:25:06 linux-rq7w kernel: device eth0 left promiscuous mode
Jun 30 15:26:28 linux-rq7w sshd[18266]: Accepted publickey for remote-bk from 66.126.187.197 port 15753 ssh2
Jun 30 15:26:39 linux-rq7w kernel: device eth0 entered promiscuous mode
Jun 30 15:26:46 linux-rq7w kernel: device eth0 left promiscuous mode

The first attempt with tcpdump got gmail traffic, the second showed no
IP packets at all. Anyway, I was sure before and certain now that either
the traffic is blocked or my local (home) sshd is not setting up the
socket for port 3353.

You asked, ``Have you tried momentarily stopping iptables on your home
machine to see if you can connect?'' Perhaps I've oversold my skills.
I don't know what that means.

Thanks - Bruce

P.S. if you want to contact me directly: bruce.korb at the google mail domain.
If we ever figure this out, I'll post a summary here.
 
Old 06-30-2008, 07:34 PM   #10
bkorb
GNU Contributor
 
Registered: Sep 2006
Location: Sta. Cruz, CA
Distribution: openSUSE
Posts: 62

Original Poster
Rep: Reputation: 17
-o ExitOnForwardFailure=yes does not work as advertised.
I am no longer sure exactly what it does, but when I re-installed,
the host key changed. When the host key changes, -o StrictHostKeyChecking=no
will allow the connection to go through, but port forwarding is disabled.
Since the connection went through, I was fooled into believing that
the port ought to have been forwarded.

Short moral of the story: "ssh" sessions should be started by hand, not
in cron jobs.

Longer moral: If IT has procedures in place to occasionally shoot down processes
holding connections open "for too long", then you have to have an automated
restart. Don't use -o StrictHostKeyChecking=no or it fails in mysterious ways.
Avoid re-installing. If you re-install, save your keys for the new installation.

Thank you to all who helped think about the issues.

Regards, Bruce
 
Old 06-30-2008, 09:32 PM   #11
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
Glad you got it sorted

Good wrap-up, too!
 
Old 07-01-2008, 08:29 AM   #12
bkorb
GNU Contributor
 
Registered: Sep 2006
Location: Sta. Cruz, CA
Distribution: openSUSE
Posts: 62

Original Poster
Rep: Reputation: 17
One more teeny addendum for prosterity: The ssh maintainer
is fixing the bug wherein -o ExitOnForwardFailure=yes failed
to work. So OpenSSL something-after-0.9.8g will be fixed.
 
Old 07-01-2008, 09:04 AM   #13
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
Quote:
From: dtucker@cvs.openbsd.org
Subject: CVS: cvs.openbsd.org: src
Date: July 1, 2008 12:20:52 AM PDT
To: source-changes@cvs.openbsd.org

CVSROOT: /cvs
Module name: src
Changes by: dtucker@cvs.openbsd.org 2008/07/01 01:20:52

Modified files:
usr.bin/ssh : sshconnect.c

Log message:
Check ExitOnForwardFailure if forwardings are disabled due to a failed
host key check. ok djm@
It just got committed.

BTW, that's OpenSSH, not OpenSSL. It will likely be something like 5.1p1.

Last edited by chort; 07-01-2008 at 09:06 AM.
 
  


Reply



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
Connection refused on TCP port dabeeler Linux - Enterprise 5 04-29-2008 02:01 PM
port 25 connection refused even from localhost?? Ed1952 Red Hat 2 11-15-2005 08:24 AM
Connection refused error for port 25 jgnasser Linux - Networking 3 08-25-2004 07:09 AM
SSH port...Connection....refused?? Miyamoto Mandriva 6 08-26-2003 04:03 PM
port 22: connection refused lkalman Linux - Networking 13 06-17-2003 07:55 PM

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

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