SSH Tunnel to DB. unknown option -- h

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

SSH Tunnel to DB. unknown option -- h

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 used the following commands to establish the tunnel

 

 

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

 

I am getting the following error after password validation.

 

Vault password is required in order to continue.

Vault password:

 

This session is being recorded

unknown option -- h

usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]

      [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]

      [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]

      [-i identity_file] [-J [user@]host[:port]] [-L address]

      [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]

      [-Q query_option] [-R address] [-S ctl_path] [-W host:port]

      [-w local_tun[:remote_tun]] destination [command]

Connection to 10.135.114.229 closed.

 

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

 

Has anyone had this problem?

1 accepted solution

Accepted Solutions

Hi,

 

Your connection string should look something like this:

ssh -L 5000:127.0.0.1:8000 vaultuser@[email protected]#22#[email protected]

Where:

1.1.1.1 = TargetMachine

22 = TargetPort (usually 22)

8000 = tunnel target port

1.2.3.4 = PSMP address

 

Also make sure you have the PSMP-SSH CC linked to your platform have it configured to accept tunnel.

View solution in original post

6 REPLIES 6

L4 Transporter

Hi,

 

The machine where you are running the DB service also runs a SSH server?

 

Looks like it is failling when opening the SSH session from the PSMP to the target machine.

Hello

 

Yes the target machine allows ssh connections.

I use psmp to connect to the target machine over ssh with no problems.

When I try to create the tunnel the way I mentioned above, I get this error.

I checked with a tcpdump if some traffic arrived at the destination machine and not even the connection request arrives there.

 

 

Hi,

 

Try this one:

 

ssh -L localPort:127.0.0.1:tunneltargetPort VaultUser@TargetUser#TargetDomain@TargetMachine#TargetPort# tunneltargetPort@proxyaddress

TargetDomain is optional.

Hello

 

I tried using this syntax.

 

ssh -L localport:127.0.0.1:target port vaultuser@targetaccount@targetaddress tunneltargetport@proxyaddress

 

Authentication is then requested as follows:

vaultuser@targetaccount@proxyaddress's password:

If the authentication was being requested by the proxy I think it should be something like this:

vaultuser@targetaccount@targetaddress@proxyaddress's password

And invariably the authentication fails when I put my vaultuser password

 

When looking at the logs on the target host I find that instead of using proxy authentication with the targetuser, the authentication is rejected on the target server:

 

Failed password for invalid user vaultuser@targetaccount from sourceip port xxxx ssh2

 

Hi,

 

Your connection string should look something like this:

ssh -L 5000:127.0.0.1:8000 vaultuser@[email protected]#22#[email protected]

Where:

1.1.1.1 = TargetMachine

22 = TargetPort (usually 22)

8000 = tunnel target port

1.2.3.4 = PSMP address

 

Also make sure you have the PSMP-SSH CC linked to your platform have it configured to accept tunnel.

L2 Linker

For others here are some additional examples with this syntax (Option 1) for SSH Tunneling:

ssh -L localPort:127.0.0.1:tunneltargetPort VaultUser@TargetUser[#TargetDomain]@TargetMachine#TargetPort# tunneltargetPort@proxyaddress

 

I'm going to simplify some of the above and provide examples with:

VaultUser=VU

TargetUser=TU

[TargetDomain]=DM [usage depending on use case]

TargetMachine=1.1.1.1

**TargetPort=22

localPort=5000

tunneltargetPort=8000

PSMPaddress=1.2.3.4

 

** TargetPort is required to be specified; even if it is the default port 22 - this is the port the target SSHD server is listening on, in order to start the Port Forwarding of the tunneltargetPort

 

Example for a basic 'local' target account:

# ssh -L 5000:127.0.0.1:8000 vu@[email protected]#22#[email protected]

Example for a domain target account:

# ssh -L 5000:127.0.0.1:8000 vu@tu#[email protected]#22#[email protected]

Example for a vault user domain account = [email protected] (** Need to configure additional delimiter, exampled using '%')

# ssh -L 5000:127.0.0.1:8000 [email protected]%tu#dm%1.1.1.1#22#[email protected]

  • 1 accepted solution
  • 580 Views
  • 6 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!