Windows 10에서 Datagrip을 클라이언트로 사용하여 SSH 터널을 통해 원격 mysql 서버에 연결하려고 하면 "SSH 터널 생성 실패: 열기 실패" 메시지가 나타납니다.
다음을 사용하여 성공적으로 터널을 설정하고 연결할 수 있습니다 ssh username@mysqlServer -L 22:remoteHost:3306
.
연결을 테스트할 때 일부 디버그 정보를 제공하기 때문에 문제의 주요 데모로 Datagrip을 사용하고 있지만 dbeaver와 tableplus에서 시도했지만 둘 다 연결에 실패했습니다.
내 조직의 다른 사용자는 macos 컴퓨터에서 원격 mysql 서버에 정상적으로 연결할 수 있습니다.
Datagrip의 로그:
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"를 사용해 보았는데 이상하게도 즉시 작동했습니다. 다른 클라이언트를 다시 한 번 시도했지만 어느 클라이언트도 성공적으로 연결되지 않았습니다. 이것은 단지 해결 방법일 뿐이고 원래 문제를 해결하거나 밝히지 않기 때문에 답변으로 추가하지 않습니다.