Search code examples
databaseoracle-databasesshsqlplusdatabase-administration

How to connect to a database using SSH connection type using Oracle SQLPlus?


I need to connect to a database which can be accessed only through a jump server.

I can access this easily using the SSH host setup using the key file (pem file) and then adding the connection with connection type of SSH in Oracle SQL Developer.

But what I would like is to connect the same database using SQLPlus rather than using SQLDeveloper.

I searched for this in many questions and blogs but couldn't get a proper answer but most of the answers were around the SQLDeveloper setups for this than SQLPlus.

Can anyone please help me with this?


Solution

  • If you have

    • Ahost: Your Machine
    • Bhost: Jump Box
    • Chost: DB Server

    Default port:1521

    Tunnel port:1621 (just for the example)

    Then if you want to connect with SQLPlus running on Ahost, then you need to establish a connection from [Ahost] to [Bhost] with a tunnel to [Chost] this way:

    ssh -NL 1621:Chost:1621 Bhost -> just leave the session running there.

    then you can start a connection with sqlplus with destination host:port as localhost:1621

    if you are using Putty you can achieve this by using: SSH -> Tunnels option under the SSH session options