Access db behind ssh tunnel using PSM for SSH

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Welcome Idira to LIVEcommunity!

Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.

Meet Idira

Access db behind ssh tunnel using PSM for SSH

L1 Bithead

I need to access a database, but the port is not available from the office network.

For that I use an ssh tunnel to the host where the DB is running.

However when trying to use CyberArk to establish the tunnel and communicate with the BD the connection fails.

 

I can set up an SSH tunnel using PAM, but the DB connection fails.

 

I used the following commands to establish the tunnel

ssh -L 3306:127.0.0.1:3306 <Vault User>@<target user>@<target host<@<proxy address>   ssh -L 3306:127.0.0.1:3306 -t PSMConnect@<proxy address> <Vault user> <target user> <target address> -tunnel <port>

 

I linked the target's account to a platform where I allowed the tunnel through port 3306

 

Using DB client (DBeaver) I am getting the following error:

 

Could not connect to address=(host=127.0.0.1)(port=39749)(type=master) : Could not connect to 127.0.0.1:39749 : unexpected end of stream, read 0 bytes from 4 (socket was closed by server ) Could not connect to 127.0.0.1:39749 : unexpected end of stream, read 0 bytes from 4 (socket was closed by server) Could not connect to 127.0.0.1:39749 : unexpected end of stream, read 0 bytes from 4 (socket was closed by server) unexpected end of stream, read 0 bytes from 4 (socket was closed by server) unexpected end of stream, read 0 bytes from 4 (socket was closed by server)

When trying to use curl to connect to port 3309 I am getting the following error:

 

curl -v 127.0.0.1:3306 * Rebuilt URL to: 127.0.0.1:3306/ * Trying 127.0.0.1... * TCP_NODELAY set * Connected to 127.0.0.1 (127.0.0.1) port 3306 (#0) > GET / HTTP/1.1 > Host: 127.0.0.1:3306 > User-Agent: curl/7.55.1 >Accept: */* > * Recv failure: Connection was reset * Closing connection 0 curl: (56) Recv failure: Connection was reset

 

In the PSMP sshd configuration I activated the following parameters:

AllowTcpForwarding yes PermitTunnel yes

In the PSMP logs I can see the following messages:

 

[09/15/2021 | 09:40:51] | :: | PSMPPS003E [a223beea-1600-11ec-9dca-005056a7407b] PSM SSH Proxy exception occurred. 273E [a223beea-1600-11ec-9dca-005056a7407b] Failed to get Tunneling port allocated for session (Codes: -1, -1)

 

Has anyone had this problem?

1 accepted solution

Accepted Solutions

L1 Bithead

Few things to consider :

  • Did you checked the connectivity between your PSMP server and your database server on the port 3306 ?
  • How the PSMP was installed ? If you choose the integrated mode the tunneling is not supported
  • Why do you provide 2 commands to open the tunnel ? Only the second one is necessary
  • Try also to get verbose information from the client (ssh -vvv) it's sometimes useful

View solution in original post

4 REPLIES 4

L1 Bithead

Hi Luis,

 

Did you updated the platform accordingly to allow port 3306 for tunneling ?

 

https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/Latest/en/Content/PASIMP/Configuring-SSH-Tunneling-for-PSMP.htm?Highlight=ssh%20tunell

L1 Bithead

Hi Gotz

 

Yes i updated the platform to allow tunneling on port 3306.

 

Field_Content_versions_oct20__0682J00000G9AV6QAN.png

L1 Bithead

Few things to consider :

  • Did you checked the connectivity between your PSMP server and your database server on the port 3306 ?
  • How the PSMP was installed ? If you choose the integrated mode the tunneling is not supported
  • Why do you provide 2 commands to open the tunnel ? Only the second one is necessary
  • Try also to get verbose information from the client (ssh -vvv) it's sometimes useful

L1 Bithead

Hello Gotz

 

Thanks for the answer

 

Finaly i got the connection to work.

 

One of the problems was in the FW of the target system which was blocking the traffic.

Another problem was in the DB itself whose user did not have permissions to connect from the PSMP IP address.

Finally, the DB client does not allow using the commands needed to establish the tunnel as required by CyberArk.

So I had to manually log into the command line with the syntax:

 

ssh -vv -L 3306:127.0.0.1:3306 -t PSMConnect@<proxy address> <Vault user> <target account> <target address> -tunnel 3306

 

And on the client specify only as address of DB 127.0.0.1 and port 3306.

 

 

 

  • 1 accepted solution
  • 1172 Views
  • 4 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!