LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-23-2008, 09:14 AM   #1
eludlow
LQ Newbie
 
Registered: May 2004
Posts: 3

Rep: Reputation: 0
SSH port binding and timing out - some questions


I hope someone can explain to me how this is working, and help with a solution to a question I will ask in a minute!

My company website is hosted on one server (let's call it fileserver) while the mySQL databases that drive the site are on another server (let's say dbserver).

Now as far as I can make out, the only host that is allowed to connect to dbserver is fileserver - when I want to connect to the dbserver to make changes to the database, I run the following SSH command on my PC:

Quote:
ssh -L 3306:dbserver:3306 -N user@fileserver
My understanding is that this creates an SSH connection to fileserver, and binds port 3306 of dbserver to 3306 on my local machine. When I'm connected using this, I just connect to server 127.0.0.1 (ie my machine) and "it is" the dbserver's databases.

Hope you're still with me so far . . . !

First question is why does the above command need to mention both dbserver and fileserver - surely all I'm doing is binding the port from dbserver to mine - why does the connection need to go through fileserver?

Now, I've just set up a new Ubuntu server here, one purpose being to perform a nightly back up of the mySQL database. As the owners of dbserver won't allow my server to connect directly to theirs, I'm stuck using the above command, which isn't a problem except that it times out after ten minutes or so of inactivity. The solution I've thought of to this is to send a command every minute (using cron) to the mySQL server running on 127.0.0.1 (which when port bound IS my remote dbserver) just to keep the SSH connection active.

Question is, and I think this is pretty basic, how do I run the above command and then close the terminal session I've opened it in? I'm running Ubuntu server edition so only access to it is through SSH.

Hope this makes sense?

Thanks a lot,
Ed Ludlow

PS have tried using SSH keys to connect but apparently the owners of dbserver don't want to allow this.
 
Old 10-23-2008, 09:50 AM   #2
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
You're creating an ssh tunnel through the file server to the dbserver. The dbserver won't allow connections from anywhere else, which is why you cannot just forward a local port directly to the dbserver.

It sounds like there's a firewall between either your client and the fileserver, or the fileserver and the dbserver, or both, that is timing out it's temporary state after inactivity. OpenSSH has some keep-alive options mentioned in the man pages. I think you'll find reading them educational.

Code:
$ man ssh
$ man ssh_config
 
Old 10-23-2008, 09:53 AM   #3
eludlow
LQ Newbie
 
Registered: May 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks chort.

Done a bit of reading since posting that and have found -f which runs the connection in the background.

Thanks - having a play with scripts to keep the connection alive now!

Ed
 
  


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
Timing questions boo_matic Linux - Kernel 5 03-04-2008 09:00 PM
binding port mokku Linux - Newbie 4 11-10-2007 05:51 PM
Howto do Secured ssh from port https or port80(standard) to ssh d listening port 22 ? Xeratul Linux - General 4 11-23-2006 06:09 AM
SSH remote command not timing out tajsss Other *NIX 5 04-28-2005 06:57 AM
SSH timing out/not connecting NeccoWolf Linux - Networking 2 01-26-2003 02:01 PM

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

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