測試連線時從 datagrip 接收“SSH 隧道建立失敗:開啟失敗”

測試連線時從 datagrip 接收“SSH 隧道建立失敗:開啟失敗”

當嘗試使用 Windows 10 上的 datagrip 作為客戶端透過 ssh 隧道連接到遠端 mysql 伺服器時,我收到「SSH 隧道建立失敗:開啟失敗」。

我能夠使用以下命令成功建立並連接到隧道:ssh username@mysqlServer -L 22:remoteHost:3306

我使用datagrip作為問題的主要演示,因為它在測試連接時提供了一些調試信息,但我在dbeaver和tableplus上嘗試過,都無法連接。

我組織中的其他使用者能夠在 Macos 電腦上正常連接到遠端 mysql 伺服器。

來自資料夾的日誌:

2022-04-18 14:58:14,313 [  57564]   INFO - n.s.s.t.r.JCERandom - Creating new SecureRandom.
2022-04-18 14:58:14,411 [  57662]   INFO - #c.i.s.i.s.sshj - Client identity string: SSH-2.0-IntelliJ__DataGrip_DB-221.5080.224__SSHJ_0.32.0_idea2
2022-04-18 14:58:14,508 [  57759]   INFO - #c.i.s.i.s.sshj - Server identity string: SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
2022-04-18 14:58:15,258 [  58509]   INFO - #c.i.s.i.s.sshj - Authentication log: SSH connection to username@mysqlServer:22
 * With altered connection settings:
  - authMethods: PublicKey(privateKeys=[C:\Users\spenc\.ssh\id_rsa, C:\Users\spenc\.ssh\id_dsa, C:\Users\spenc\.ssh\id_ecdsa, C:\Users\spenc\.ssh\id_ed25519, C:\Users\spenc\.ssh\id_xmss], agent=NO), Password, KeyboardInteractive
  - user: username
 * Connected: Socket[addr=mysqlServer/mysqlServer,port=22,localport=63766]
 * Starting authentication
  => none (failure, new auth methods allowed by the server: publickey)
  => publickey C:\Users\spenc\.ssh\id_rsa (success)
2022-04-18 14:58:15,270 [  58521]   INFO - #c.i.d.d.DatabaseSshTunnelEstablisher - SSH tunnel created: 63768:remoteHost:3306
2022-04-18 14:58:15,317 [  58568]   INFO - #c.i.e.r.RemoteProcessSupport - "C:\Program Files\JetBrains\DataGrip 2022.1.1\jbr\bin\java" -Djava.rmi.server.hostname=127.0.0.1 -Duser.timezone=UTC -Xmx750m -Xms128m -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\DataGrip 2022.1.1\lib\util_rt.jar;C:\Program Files\JetBrains\DataGrip 2022.1.1\lib\util.jar;C:\Program Files\JetBrains\DataGrip 2022.1.1\lib\groovy.jar;C:\Program Files\JetBrains\DataGrip 2022.1.1\plugins\DatabaseTools\lib\jdbc-console.jar;C:\Users\spenc\AppData\Roaming\JetBrains\DataGrip2022.1\jdbc-drivers\MySQL ConnectorJ\8.0.25\mysql-connector-java-8.0.25.jar" com.intellij.database.remote.RemoteJdbcServer com.mysql.cj.jdbc.Driver
2022-04-18 14:58:15,705 [  58956]   INFO - #c.i.e.r.RemoteProcessSupport - Port/ServicesPort/ID: 58696/63770/RemoteDriverImpld6de775c
2022-04-18 14:58:15,713 [  58964]   INFO - #c.i.e.r.RemoteProcessSupport - 
2022-04-18 14:58:15,772 [  59023]   INFO - #c.i.d.d.DatabaseConnectionEstablisher - Connecting to: jdbc:mysql://remoteHost:3306/dbName
2022-04-18 14:58:15,774 [  59025]   INFO - #c.i.d.d.DatabaseConnectionEstablisher - Auth provider: user-pass
2022-04-18 14:58:15,776 [  59027]   INFO - #c.i.d.d.DatabaseCredentialsAuthProvider - Connecting as: username
2022-04-18 14:58:15,778 [  59029]   INFO - #c.i.d.d.DatabaseConnectionEstablisher - Connecting to (rewritten): jdbc:mysql://localhost:63768/dbName
2022-04-18 14:58:15,987 [  59238]   WARN - #c.i.s.i.s.sshj - <<chan#0 / open>> woke to: Opening `direct-tcpip` channel failed: open failed
2022-04-18 14:58:15,989 [  59240]   INFO - #c.i.s.i.s.sshj - Error in `SSHJ local tunnel for SshjSshConnection(username@mysqlServer)@82260ee: Local client /127.0.0.1:63774 ==> Local server localhost:63768 ==> Remote server remoteHost:3306`: net.schmizz.sshj.connection.channel.OpenFailException: open failed
2022-04-18 14:58:16,016 [  59267]   WARN - #c.i.d.d.BaseDatabaseErrorHandler$IOErrorInfo - Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
    at com.mysql.cj.protocol.FullReadInputStream.readFully(FullReadInputStream.java:67)
    at com.mysql.cj.protocol.a.SimplePacketReader.readHeader(SimplePacketReader.java:63)
    at com.mysql.cj.protocol.a.SimplePacketReader.readHeader(SimplePacketReader.java:45)
    at com.mysql.cj.protocol.a.NativeProtocol.readMessage(NativeProtocol.java:540)
    at com.mysql.cj.protocol.a.NativeProtocol.readServerCapabilities(NativeProtocol.java:498)
    at com.mysql.cj.protocol.a.NativeProtocol.beforeHandshake(NativeProtocol.java:385)
    at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1351)
    at com.mysql.cj.NativeSession.connect(NativeSession.java:157)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:953)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
    at com.intellij.database.remote.jdbc.helpers.JdbcHelperImpl.connect(JdbcHelperImpl.java:639)
    at com.intellij.database.remote.jdbc.helpers.MysqlBaseJdbcHelper.connect(MysqlBaseJdbcHelper.java:244)
    at com.intellij.database.remote.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:55)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
    Suppressed: com.intellij.database.util.AsyncTask$Frame$FrameData: Async frame data: Test Connection -> Prepare connection -> Establish database connection -> Get database credentials -> Perform database connection
2022-04-18 14:58:16,019 [  59270]   INFO - #c.i.e.r.RemoteProcessSupport - Terminating: 127.0.0.1:58696/RemoteDriverImpld6de775c
2022-04-18 14:58:16,054 [  59305]   INFO - #c.i.e.r.RemoteProcessSupport - Process finished with exit code -1

更新:我嘗試了適用於 Windows 的“MySQL Workbench”,並且神秘地立即起作用了。我再次嘗試了其他客戶端,但沒有一個成功連線。我不會將其添加為答案,因為它只是一種解決方法,不能解決或闡明原始問題。

相關內容