»   »   »

Connecting to an Oracle Database via an SSH Tunnel from Windows or GNU/Linux

Prelude

I needed to connect to my Oracle database that I run on my GNU/Linux home server from work, the method that I usually connect to my server is via SSH (Secure Shell).

tnsnames.ora

Modify your tnsnames.ora file to have an entry for your remote database, note that I have chosen the port 2200, but you can choose any port:

ROQDB.WORLD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 2200))
    (CONNECT_DATA =
      (SID = ROQDB)
    )
  )
    

Tunneling via PuTTY

PuTTY is an SSH client that runs on Windows, you can get it from here.

In the Connection -> SSH -> Tunnels section, add a Source Port of 2200 (or any you choose to match the tnsnames.ora file and a Destination of localhost:1521.

Tunneling via SSH

From another GNU/Linux machine, or a Windows machine running Cygwin, you can create a tunnel by running the following command:

ssh user@remote -L2200:localhost:1521
    

© Roqet :: 2022-03-01 16:07:34