Connect to database hosted on SSH machine with Oracle SQL Developer

Viewed 24

I would like to connect to an Oracle database hosted on a remote box using Oracle SQL Developer. I am able to create a standard connection BUT I have to be connected to a VPN for security reasons. I want to bypass this vpn.

I do this all the time with normal ssh connections. There is one machine (gateway) on my company network than can be accessed outside the network (no vpn). From gateway, I can connect to any machine on our network. I would like to connect to the database hosted on machine (dbmachine) on the network (which cannot be accessed without being on the vpn unless I am first connected to the gateway).

This seems to be a common issue because I was easily able to bake this functionality seamlessly into my ssh config. Example:

Host gateway
     HostName gateway.company.org
     User marc

Host dbmachine
     HostName dbmachine.company.org
     User marc
     ProxyJump gateway

Host exampleMachine
     HostName exampleMachine.company.org
     User marc
     ProxyJump gateway

By using ProxyJump, I am able to type ssh dbmachine to seamlessly connect to dbmachine or ssh exampleMachine to seamlessly connect to exampleMachine. I want to do a similar jumping technique with Oracle SQL Developer. How can I connect to the database on dbmachine from Oracle SQL Developer?

I'm not sure what port the db is running on dbmachine, but I can access it though sqlplus when I'm logged into the box.

1 Answers

The answer is to create an SSH Tunnle:

ssh -L 1521:localhost:1521 -N -f dbmachine

This will forward all traffic on localhost:1521 to dbmachine:1521 (where the database is running). It will respect the user's configuration so you do not have to setup two tunnles.

-N Will not switch to remote shell -f Requests ssh to go to background just before command execution

I'm not sure if there's a better solution that is configurable directly in a database client, but this works for me on Arch Linux.

Related