Connect to Oracle Database server through ssh tunnel

Last week I needed to connect a database from remote using VPN.
The VPN is connected to a secured network, so I couldn’t connect directly to the database.
Since I am using Toad for Oracle which is based on oracle client – I needed a transparent solution for that connection.



At the past I wrote a post about Using ssh X11 tunnel through a bastion host to connect to a database server , at that post I described how to forward SSH and X11.
Now I will describe a way to connect to the database using SQL*Net (usually port 1521) on Windows.

Download plink from https://www.putty.org , you can download putty package or just standalone plink.
Run the following command line:
plink -N -L localport:dbserver:dbport getwayuser@getwayserver
Do this on both machines (REMOTE PC Windows machine and the server you have access to - Gateway) to chain the SSH tunnels.

Example:

Gateway server (assuming Linux):
ssh -N -L1521:dbserver:1521 dbserveruser@dbserver
Your PC:
plink -N -L 1521:getwayserver:1521 getwayuser@getwayserver
The tnsnames.ora entry must look like you are running a local database, e.g.
dboverssh =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = crm)
    )
  )

Comments

Popular posts from this blog

Data Guard - Changing IP Addresses

Install Oracle Internet Directory (OID) in Standalone mode

Fixing & Registering ORACLE_HOMES in Central Inventory