Not able to connect with cassandra db which have multiple ssh tunnel

Answered

I am trying to setup my remote cassandra db with datagrip which goes through multiple hops.

local machine -> ssh to bastion -> ssh to remote-cql -> cqlsh to login to cassandra db.

I am not able to setup multiple hop in datagrip. first tunnel I did and that was successful but not able to setup second one.

tried using ~/.ssh/config I am able to do using terminal but the same not working with datagrip.

Host bastion
    Hostname 10.0.0.1
    User qwerty
    IdentityFile ~/.ssh/jumpcloud
Host remote-cql
    Hostname 10.0.0.2
    User qwerty
    ProxyCommand ssh -W %h:%p bastion
    LocalForward 9042 localhost:9042
    ProxyJump bastion
    ForwardAgent yes

if i do ssh remote-cql,  it allows me to login to db node.
but same not able to connect with datagrip.

0
8 comments

Hello,

Am I got you right that at first you try to establish ssh connection to bastion which fails? Is it possible to attach idea.log ("Help | Show Log in...") after testing connection to check recorded events? 

0

Hey Yaroslav Bedrov, thanks for having a look into this.
Bastion connection is successful if i try with  key-pair option where I provide my key passphrase file.
But I don't have option to establish another ssh tunnel, So tried to do using config which I put it as sample that is not working, seems to be not able to read or parse it properly.

0

Hey, what if i don't have a identity file for private server?

0
2023-05-13 20:25:45,420 [29786440]   INFO - #c.i.s.i.s.sshj - Error from SSHJ local tunnel for SshjSshConnection(userName@bastionIP)@92f26e8: Local client /127.0.0.1:53362 ==> Local server 127.0.0.1:53356 ==> Remote server cassandraDBIP:9042 while was closing < direct-tcpip channel: id=0, recipient=0, localWin=[winSize=2097047], remoteWin=[winSize=2097027] >
net.schmizz.sshj.connection.ConnectionException: Disconnected
    at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:32)
    at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:26)
    at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
    at net.schmizz.concurrent.Event.deliverError(Event.java:74)
    at net.schmizz.concurrent.ErrorDeliveryUtil.alertEvents(ErrorDeliveryUtil.java:34)
    at net.schmizz.sshj.connection.channel.AbstractChannel.notifyError(AbstractChannel.java:239)
    at net.schmizz.sshj.common.ErrorNotifiable$Util.alertAll(ErrorNotifiable.java:35)
    at net.schmizz.sshj.connection.ConnectionImpl.notifyError(ConnectionImpl.java:261)
    at net.schmizz.sshj.transport.TransportImpl.disconnect(TransportImpl.java:406)
    at net.schmizz.sshj.transport.TransportImpl.disconnect(TransportImpl.java:397)
    at net.schmizz.sshj.transport.TransportImpl.disconnect(TransportImpl.java:392)
    at net.schmizz.sshj.SSHClient.disconnect(SSHClient.java:439)
    at com.intellij.ssh.impl.sshj.PlatformSSHClient.disconnect(SshjConnectionUtil.kt:605)
    at net.schmizz.sshj.SSHClient.close(SSHClient.java:842)
    at com.intellij.ssh.impl.sshj.SshjSshConnection$disconnect$4.invoke(SshjSshConnection.kt:187)
    at com.intellij.ssh.impl.sshj.SshjSshConnection$disconnect$4.invoke(SshjSshConnection.kt:187)
    at com.intellij.ssh.impl.sshj.SshjSshConnection.disconnect(SshjSshConnection.kt:190)
    at com.intellij.database.console.JdbcDriverManagerImpl.destroyTunnelImpl(JdbcDriverManagerImpl.java:277)
    at com.intellij.database.console.JdbcDriverManagerImpl.destroyTunnelImpl(JdbcDriverManagerImpl.java:271)
    at com.intellij.database.console.JdbcDriverManagerImpl.destroyTunnel(JdbcDriverManagerImpl.java:266)
    at com.intellij.database.console.JdbcDriverManagerImpl.lambda$releaseDriver$2(JdbcDriverManagerImpl.java:202)
    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: net.schmizz.sshj.transport.TransportException: [BY_APPLICATION] Disconnected
    ... 23 more

vasily chernov I have some logs which might be helpful.
FYI, I am able to make ssh tunnel using below config.

Host bastion
    Hostname 10.0.x.x
    User qwerty
    IdentityFile ~/.ssh/jumpcloud
Host eu1a-cql
    Hostname 10.0.y.y
    User qwerty
    ProxyCommand ssh -W %h:%p bastion

while trying to connect with DB in general tab I am providing the cassandra db ip and Authentication type is user & password.

0

Some missing logs

2023-05-13 20:25:44,353 [29785373]   INFO - #c.i.e.r.RemoteProcessSupport - Desktop actions are jbr-api
2023-05-13 20:25:44,414 [29785434]   INFO - #c.i.e.r.RemoteProcessSupport - Port/ServicesPort/ID: 36260/53357/RemoteDriverImpl4c03adfe
2023-05-13 20:25:44,431 [29785451]   INFO - #c.i.d.d.DatabaseConnectionEstablisher - Connecting to: jdbc:cassandra://cassandraIP:9042/
2023-05-13 20:25:44,432 [29785452]   INFO - #c.i.e.r.RemoteProcessSupport - 
2023-05-13 20:25:44,432 [29785452]   INFO - #c.i.d.d.DatabaseConnectionEstablisher - Auth provider: user-pass
2023-05-13 20:25:44,432 [29785452]   INFO - #c.i.d.d.DatabaseCredentialsAuthProvider - Connecting as: qwerty
2023-05-13 20:25:44,432 [29785452]   INFO - #c.i.d.d.DatabaseConnectionEstablisher - Connecting to (rewritten): jdbc:cassandra://localhost:53356/
2023-05-13 20:25:44,456 [29785476]   WARN - #c.i.e.r.RemoteProcessSupport - SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2023-05-13 20:25:44,456 [29785476]   WARN - #c.i.e.r.RemoteProcessSupport - SLF4J: Defaulting to no-operation (NOP) logger implementation
2023-05-13 20:25:44,456 [29785476]   WARN - #c.i.e.r.RemoteProcessSupport - SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2023-05-13 20:25:44,485 [29785505]   WARN - #c.i.e.r.RemoteProcessSupport - May 13, 2023 2:55:44 PM com.dbschema.CassandraClientURI createCluster
2023-05-13 20:25:44,485 [29785505]   INFO - #c.i.e.r.RemoteProcessSupport - Using authentication as user 'qwerty'
2023-05-13 20:25:44,485 [29785505]   WARN - #c.i.e.r.RemoteProcessSupport - INFO: sslenabled: false
2023-05-13 20:25:45,375 [29786395]   WARN - #c.i.d.d.DatabaseConnectionEstablisher - Connecting to: jdbc:cassandra://localhost:53356/
2023-05-13 20:25:45,375 [29786395]   WARN - #c.i.d.d.DatabaseConnectionEstablisher - Authentication error on host localhost/127.0.0.1:53356: Failed to login. Please re-try.
2023-05-13 20:25:45,376 [29786396]   INFO - #c.i.e.r.RemoteProcessSupport - Terminating: 127.0.0.1:36260/RemoteDriverImpl4c03adfe
2023-05-13 20:25:45,419 [29786439]   INFO - #c.i.e.r.RemoteProcessSupport - Process finished with exit code 137 (interrupted by signal 9: SIGKILL)
2023-05-13 20:25:45,420 [29786440]   INFO - #c.i.s.i.s.sshj - Disconnected - BY_APPLICATION
2023-05-13 20:25:45,420 [29786440]   WARN - #c.i.s.i.s.sshj - <<chan#0 / close>> woke to: net.schmizz.sshj.connection.ConnectionException: Disconnected
0

>Hey, what if i don't have a identity file for private server?

Then remove that line from config file.

0

Have you tried to set up SSH tunnel in console / terminal to connect to Cassandra?

In the logs, I can see the following error:

Authentication error on host localhost/127.0.0.1:53356: Failed to login. Please re-try

It appears that you are attempting to connect to the local host. Have you tried providing the IP address of your Cassandra instance in the network where you are trying to establish the tunnel?

0

Please sign in to leave a comment.