Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-16-2010, 09:07 AM   #1
LQ Newbie
Registered: Nov 2010
Posts: 2

Rep: Reputation: 0
Can't connect to remote database

Hey guys, noob here. Hopefully this is the right place to post this. I'm trying to connect to a remote database but can't connect directly (I think due to security reasons). Here's the setup:

Computer A - my computer
Computer B - server, I can SSH to this from computer A
Computer C - server that runs database, I can SSH to this from B but can't from A

Any ideas how I can can connect to C directly from A? I think I need to setup a tunnel or something like that but I can't figure it out.
Old 11-16-2010, 09:31 AM   #2
LQ Newbie
Registered: Nov 2006
Posts: 20

Rep: Reputation: 10
You already have a "tunnel" if you can chain SSH sessions, A-B-C.

It's kind of difficult to provide a solution, because it is not clear what resources you have (e.g., can you manage computer "B?") and what the constraints are (e.g., what protocols can you use to reach "B?"). You might want to post a little more information about what the computers B and C do, and what sort of remote connection to the database you want.

For example: Your computer is at home/office, B and C are at (remote) office/host provider. If "B" is a web server, and "C" is the database server behind the web server, AND you are using MySQL, phpMyAdmin on the web server is an option.

Last edited by cjturner; 11-16-2010 at 09:32 AM.
Old 11-16-2010, 10:39 AM   #3
LQ Newbie
Registered: Nov 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for the response. Here's a little more info.

Computer A is my Windows computer (note: I also have a Mac, so if things are easier I could use that). I'd like to connect to the database on C in 2 ways. The first is that I'd like to fire up a GUI from A and be able to check out C's tables. I'd also like to be able to run a local web server on A that uses C's database.

Computer B is kind of a utility server that I can directly SSH to. To do this, I open up Putty, supply a private key, and are authenticated on B. Once logged in remotely to B, I can SSH over to C. I believe this is possible because they're on the same network.

Computer C is the database server. I believe I can't connect directly from A to C because there is no SSH server running on it (I think for security reasons).

As far as access, I have sudo access on B and C but I'm not the root user and I probably wouldn't want to make any system changes.

Thanks again for the response.


Edit: If it helps, the database is a postgres database. I'm using Navicat Lite on my Windows machine to connect. Navicat has an option to connect via SSH but since I can't connect directly to Computer C, it doesn't work, but I was thinking if there was some way to route data from C to B, then use Navicat's SSH to connect to B, but I haven't been able to get that to work.

Last edited by cjbnt198; 11-16-2010 at 10:41 AM. Reason: adding more info
Old 11-16-2010, 11:36 AM   #4
LQ Newbie
Registered: Nov 2006
Posts: 20

Rep: Reputation: 10
As with all things, security is the first consideration. There is a reason enterprise sysadmins want databases to be unreachable from the internet, so any solution, no matter how secure it is, is going to increase the possibility that your DB server can be hacked.

Your best bet is a Reverse(or "inbound") Proxy, I should think. You'll _want_ to collaborate with the server owner, but squid is probably installed on the server and just needs enabling and configuring. I suggest that the port exposed to the internet is not the postgres standard SSH (configure NAVICAT to talk on something else and allow the proxy to convert the port.

There are some good HOW-TO's out there on squid, and it has features to keep the 'hole' in the firewall pretty narrow.


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
Dovecot imap will not connect from remote machine but will connect local charlesnorman Linux - Server 4 03-28-2019 11:20 AM
[SOLVED] Unable to connect to remote PostgreSQL database with java.derby ChrisKlinger Linux - Server 1 08-28-2010 03:06 AM
DBI Connect Failed:Access denied for user ''@'localhost' to database <database> error kaplan71 Linux - Software 3 06-05-2009 12:39 PM
MySQL and remote database inspleak Linux - Networking 3 09-17-2004 01:00 AM
Using Tora to connect to remote database devinWhalen Linux - Software 0 02-18-2004 03:15 PM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration