LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can't connect to remote database (https://www.linuxquestions.org/questions/linux-newbie-8/cant-connect-to-remote-database-844613/)

cjbnt198 11-16-2010 09:07 AM

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.

cjturner 11-16-2010 09:31 AM

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.

cjbnt198 11-16-2010 10:39 AM

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.

cjturner 11-16-2010 11:36 AM

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.


All times are GMT -5. The time now is 09:59 AM.