Posts

Showing posts from October, 2019

Connect to Oracle Database server through ssh tunnel

Image
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

Using ssh X11 tunnel through a bastion host to connect to a database server

Image
Hi, I succeeded running Oracle dbca, xclock & virt-viewer using Bastion over VPN (with root) 😊 Theoretical Steps: First, connect to machine B and forward [localPort] to C:22 through B A$ ssh -L [localPort]:C:22 B Next, connect to C from A through this newly-created tunnel using [localPort], forwarding X11 A$ ssh -X -p [localPort] localhost Now we can run X11 programs on C and have them display on A C$ xclock [localPort] can be any port that you are not already listening to on A, I often use 2222 for simplicity. X11Forwarding should be enabled on server C AllowTcpForwarding should be enabled on server B Actual Steps First, connect to machine B and forward [localPort] to C:22 through B A$ ssh -L [localPort]:C:22 B Next, connect to C from A through this newly-created tunnel using [localPort], forwarding X11 From A using putty to localhost using [localPort] enable X11 forwarding to localhost:0.0 Now we can run X11 programs on C and have them display on A