Search code examples
datagrip

How Connect Unix Socket via SSH Tunnel in Datagrip


How can I connect to a MySQL server via SSH Tunnel and get from the server the UNIX socket in Datagrip?

I found this partial solution, that helps me to configure SSH Tunnel but not get the socket file from the server. How to connect to database through SSH using DataGrip

enter image description here

enter image description here

The server is MariaDB and I tried to use this information too but doesn't work

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010247880-How-to-connect-to-mariadb-via-unix-socket-

enter image description here


Solution

  • unix socket is not forwarded via SSH tunnel unless you perform some additional steps. the best approach is to use socat. something like that before connection:

    /usr/bin/socat "UNIX-LISTEN:$SOCKET_DIR/mariadb-remote1.sock,reuseaddr,fork" \
    EXEC:'/usr/bin/ssh -F /etc/sshssh_config -l root <remote1 host> -p 22 /usr/bin/socat STDIO UNIX-CONNECT\:/run/mariadb/mariadb.sock'
    

    Here and here you can find more useful information.