SSH Tunnel connection in Datagrip - DB Redshift

Hi, I often work a lot with a Redshift database, to which I have to connect with a Putty tunnel, but it is quite tedious to have to be running Putty every time I want to connect to the DB.

- I have to open a terminal and run the following command from cmd:

putty -P 10044 -noagent -N -L 1000:digitaldev-prd-redshift-cluster-02.cdy6xysljydu.us-east-1.redshift.amazonaws.com:1000
ni_nestor.xxxxx@redshift-datalake-prd.companycloud.net -i ni_nestor.xxxxx.ppk

some values of this command are fictitious for privacy.

- Then it opens the following window containing the personal private key in Putty in which I must be entering the tunnel password.

- Then I have to minimize the window and even then I have to make the connection to the DB, or reload it.

I have tried different ways to set the SSH connection configuration from DataGrip itself, and I have not succeeded.

This is one of the configurations I have made, with Attestation Type: Key Pair PuTTy:

and when I run the test, I get the following error:

I have also tried with Authentication Type: "Password, and I get the same error.

I would be very grateful if you could help me to set up this tunnel configuration.

0
6 comments

Hi Nestorjosrey,

Please provide the idea log from Help - Show Log in Files so we can review the error messages you're getting.

0

Aleksandr Molchanov

 

2023-05-11 18:58:53,884 [121378868]   WARN - #c.i.s.i.s.sshj - Failed to connect. Brief info: SSH connection to ni_nestor.reyes@digital-prd-redshift-cluster-02.cdy6xyhljydu.us-east-1.redshift.amazonaws.com:5439
 * With altered connection settings:
  - authMethods: PublicKey(privateKeys=[C:\Users\NJT01659\Documents\C_ Programs\Putty\ni_nestor.reyes.ppk, C:\Users\NJT01659\.ssh\id_rsa, C:\Users\NJT01659\.ssh\id_dsa, C:\Users\NJT01659\.ssh\id_ecdsa, C:\Users\NJT01659\.ssh\id_ed25519, C:\Users\NJT01659\.ssh\id_xmss], agent=NO), Password, KeyboardInteractive
  - port: 5439
  - user: ni_nestor.reyes
 * Failed to connect to digital-prd-redshift-cluster-02.cdy6xyhljydu.us-east-1.redshift.amazonaws.com/34.192.115.251 port 5439
java.net.ConnectException: Connection timed out: connect
    at java.base/sun.nio.ch.Net.connect0(Native Method)
    at java.base/sun.nio.ch.Net.connect(Net.java:579)
    at java.base/sun.nio.ch.Net.connect(Net.java:568)
    at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588)
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
    at java.base/java.net.Socket.connect(Socket.java:633)
    at net.schmizz.sshj.SocketClient.connect(SocketClient.java:107)
    at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.connectPlatform(SshjConnectionUtil.kt:863)
    at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.setUpSessionForSshJ$lambda$11(SshjConnectionUtil.kt:224)
    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)

0
Thanks for the update.

After comparing the screenshots of putty settings with your DataGrip settings and log entries, I see the following discrepancies:

The port number differentiates (if no port forwarding is configured ) and I may assume the hostname can be different. 

Host : redshift-datalake-prd.companycloud.net (http://redshift-datalake-prd.companycloud.net/)
Port - 10044
Username  - `ni_nestor.xxxxx`
Auth type - key pair
Private key file - the path to `ni_nestor.xxxxx.ppk`

I'd suggest having an ssh config file and using an ssh-agent, instead of using putty. 

If you could describe your current setup, we can try to help you with setting up a tunnel.
0

Hi Aleksandr Molchanov

The values I indicated here, for example port 10044 are fictitious because I wanted to keep privacy.
I put in the description: "some values of this command are fictitious for privacy".

However, I know that in Datagrip I am putting the correct values.

And I don't know how to do this you suggest:

  • "having an ssh config file and using an ssh-agent, instead of using putty." 

I appreciate if you help me please

I rewrite the case with the correct values:

1) I have to open a terminal and run the following command from cmd:

putty -P 10044 -noagent -N -L 5439:digital-prd-redshift-cluster-02.cdy6xyhljydu.us-east-1.redshift.amazonaws.com:5439 ni_nestor.reyes@redshift-datalake-prd.tigocloud.net -i ni_nestor.reyes.ppk

2) - Then I have to minimize the window and even then I have to make the connection to the DB, or reload it.

---------------------------------------------

This is one of the configurations I have made, with Attestation Type: Key Pair PuTTy:

and this the error:

 

Log:
2023-05-12 15:50:58,735 [196503719]   INFO - net.schmizz.sshj.transport.random.JCERandom - Creating new SecureRandom.
2023-05-12 15:51:08,863 [196513847]   WARN - #c.i.s.i.s.sshj - Failed to connect. Brief info: SSH connection to ni_nestor.reyes@digital-prd-redshift-cluster-02.cdy6xyhljydu.us-east-1.redshift.amazonaws.com:5439
 * With altered connection settings:
  - authMethods: PublicKey(privateKeys=[C:\Users\NJT01659\Documents\C_ Programs\Putty\ni_nestor.reyes.ppk, C:\Users\NJT01659\.ssh\id_rsa, C:\Users\NJT01659\.ssh\id_dsa, C:\Users\NJT01659\.ssh\id_ecdsa, C:\Users\NJT01659\.ssh\id_ed25519, C:\Users\NJT01659\.ssh\id_xmss], agent=NO), Password, KeyboardInteractive
  - connectTimeout: PT10S
  - port: 5439
  - user: ni_nestor.reyes
 * Failed to connect to digital-prd-redshift-cluster-02.cdy6xyhljydu.us-east-1.redshift.amazonaws.com/34.192.115.251 port 5439
java.net.SocketTimeoutException: Connect timed out
    at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
    at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
    at java.base/java.net.Socket.connect(Socket.java:633)
    at net.schmizz.sshj.SocketClient.connect(SocketClient.java:107)
    at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.connectPlatform(SshjConnectionUtil.kt:863)
    at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.setUpSessionForSshJ$lambda$11(SshjConnectionUtil.kt:224)
    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)
2023-05-12 15:51:08,866 [196513850]   WARN - #c.i.s.u.u.SshCredentialsEditorEx - java.net.SocketTimeoutException: Connect timed out
com.intellij.ssh.SshException: java.net.SocketTimeoutException: Connect timed out
    at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.setUpSessionForSshJ(SshjConnectionUtil.kt:254)
    at com.intellij.ssh.impl.SshConnection.doSshjSshConnection(SshConnection.kt:211)
    at com.intellij.ssh.impl.SshConnection.access$doSshjSshConnection(SshConnection.kt:27)
    at com.intellij.ssh.impl.SshConnection$createSshSessionForSshj$1.invoke(SshConnection.kt:204)
    at com.intellij.ssh.impl.SshConnection$createSshSessionForSshj$1.invoke(SshConnection.kt:201)
    at com.intellij.ssh.Ssh.wrapBlockingSshCall(ssh.kt:393)
    at com.intellij.ssh.Ssh.wrapBlockingSshCall$default(ssh.kt:374)
    at com.intellij.ssh.impl.SshConnection.createSshSessionForSshj(SshConnection.kt:201)
    at com.intellij.ssh.impl.SshConnection.access$createSshSessionForSshj(SshConnection.kt:27)
    at com.intellij.ssh.impl.SshConnection$checkCanAuthenticate$1.invoke(SshConnection.kt:136)
    at com.intellij.ssh.impl.SshConnection$checkCanAuthenticate$1.invoke(SshConnection.kt:131)
    at com.intellij.ssh.Ssh.wrapBlockingSshCall(ssh.kt:393)
    at com.intellij.ssh.Ssh.wrapBlockingSshCall$default(ssh.kt:374)
    at com.intellij.ssh.impl.SshConnection.checkCanAuthenticate(SshConnection.kt:131)
    at com.intellij.ssh.SshConnectionService.checkCanAuthenticate(SshConnectionService.kt:210)
    at com.intellij.ssh.Ssh.checkCanAuthenticate(ssh.kt:262)
    at com.intellij.ssh.Ssh.access$checkCanAuthenticate(ssh.kt:1)
    at com.intellij.ssh.ConnectionBuilder.checkCanAuthenticate(ssh.kt:107)
    at com.intellij.ssh.ui.unified.SshCredentialsEditorEx$1.lambda$actionPerformed$0(SshCredentialsEditorEx.java:68)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:252)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.net.SocketTimeoutException: Connect timed out
    at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
    at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
    at java.base/java.net.Socket.connect(Socket.java:633)
    at net.schmizz.sshj.SocketClient.connect(SocketClient.java:107)
    at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.connectPlatform(SshjConnectionUtil.kt:863)
    at com.intellij.ssh.impl.sshj.SshjConnectionUtilKt.setUpSessionForSshJ$lambda$11(SshjConnectionUtil.kt:224)
    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
    ... 7 more
2023-05-12 15:52:13,589 [196578573]   INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files

 

 

0

Hi Nestorjosrey,

There's ssh tunnel with port forwarding setup in putty, but we don't see if it connects to the database with DataGrip. This can be done without specifying the ssh tab explicitly. Does it connect to the database in DataGrip with the ssh tunnel built-in via putty? If so, we need screenshots. This is just to exclude incorrect ssh tunnel setup.

If privacy is a concern, we can report this issue on our tracker so all of the configuration settings can be kept private.

Please let us know.

0

Please sign in to leave a comment.