LinuxQuestions.org
Review your favorite Linux distribution.
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 11-29-2010, 09:26 AM   #1
orwb
LQ Newbie
 
Registered: Dec 2007
Posts: 5

Rep: Reputation: 0
Reverse SSH tunnel connection problem


I am using a reverse ssh tunnel. However, sometimes the connection is broken but the server continues to think the connection is alive and well. When I try to connect to the server again I get the error:

Warning: remote port forwarding failed for listen port 2000

Issuing the following commands does NOT fix the problem:
service sshd restart
killall sshd

The only thing I have found that clears the problem and allows the client to connect is to reboot the Linux server. Can someone tell me what I am missing? My itty bitty brain can't understand why restarting the sshd service shouldn't fix the problem.

Thank you.
 
Old 11-29-2010, 10:42 AM   #2
vishesh
Member
 
Registered: Feb 2008
Distribution: Fedora,RHEL,Ubuntu
Posts: 661

Rep: Reputation: 66
Can you share sshd configuration ?. May be it give more broad idea.

Thanks
 
Old 11-29-2010, 11:27 AM   #3
orwb
LQ Newbie
 
Registered: Dec 2007
Posts: 5

Original Poster
Rep: Reputation: 0
sshd config

I posted the sshd config below.

sshd config:

Code:
#       $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

Port 22222
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6

RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication mechanism.
# Depending on your PAM configuration, this may bypass the setting of
# PasswordAuthentication, PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
# session checks to run without PAM authentication, then enable this but set
# ChallengeResponseAuthentication=no
#UsePAM no
UsePAM yes

# Accept locale-related environment variables
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
#AllowTcpForwarding yes
#GatewayPorts no
GatewayPorts clientspecified

#X11Forwarding no
X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
ClientAliveInterval 15
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server

AllowUsers root surv1 jim
 
Old 11-29-2010, 01:29 PM   #4
jlcasado
LQ Newbie
 
Registered: Oct 2010
Location: Madrid - Spain
Distribution: RHEL
Posts: 26

Rep: Reputation: 1
Hi,

Even if you restart sshd daemon, active connections will not drop.

Whenever the problem happens, check with ps if the sshd session is still there and kill it.

Also lsof could help to find out which process has the port opened.

best regards
jose
 
Old 11-29-2010, 08:19 PM   #5
orwb
LQ Newbie
 
Registered: Dec 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you. I can work with that. It doesn't happen very often anymore since I added the ClientAliveInterval but it will be a great help.

Jim
 
Old 12-01-2010, 10:56 AM   #6
orwb
LQ Newbie
 
Registered: Dec 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlcasado View Post
Hi,

Even if you restart sshd daemon, active connections will not drop.

Whenever the problem happens, check with ps if the sshd session is still there and kill it.

Also lsof could help to find out which process has the port opened.

best regards
jose
It does not show up on ps list. The only items that ps showed associated with ssh were my existing login session and the main sshd process. I killed all of them which didn't fix the problem.

Using netstat -an I noticed the connection was in the closed_wait state.
 
Old 12-01-2010, 04:16 PM   #7
jlcasado
LQ Newbie
 
Registered: Oct 2010
Location: Madrid - Spain
Distribution: RHEL
Posts: 26

Rep: Reputation: 1
Hi,

Good idea to check the socket state

Unfortunately I don't know a way to close that socket once in this state...maybe it is time to move this to the networking part of the forum....

best regards
jose
 
  


Reply

Tags
failed, forwarding, port, remote, sshd


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
Reverse SSH Tunnel Ubuntu and Windows 7 twaddlac Linux - Networking 6 10-06-2010 12:27 PM
[SOLVED] Reverse SSH tunnel edan Linux - Security 3 07-14-2010 10:37 PM
Reverse SSH tunnel active only from localhost andreag Linux - Networking 2 12-19-2006 03:05 AM
SSH reverse tunnel (lo only? why not eth0) Dinomight Linux - Networking 3 08-17-2006 10:44 PM
Reverse SSH Tunnel sniggleflop Linux - Security 1 10-13-2002 02:24 PM


All times are GMT -5. The time now is 03:57 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration