Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connect with database standing on host which requires SSH connection using Qt
Forum Updated to NodeBB v4.3 + New Features

Connect with database standing on host which requires SSH connection using Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 4 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    marcus74
    wrote on last edited by
    #6

    @hskoglund Oh I see, it argues with postgres on my local machine and when I set hostname to "localhost", it tries to connect local database rather than remote. In fact

    ssh -L 5432:localhost:5432 userFromAboveHost@host.with.database.com
    

    seems to have no effect.

    fedbdb01-9edb-4d95-a43b-6978c2a657c8-obraz.png

    Generally, db tries to establish connection with local machine postgres all the time. Local postgres listen on 5432. Any ideas how to solve that? I think that I'm going to achieve the goal but it's still far away... :(

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #7

      @marcus74 said in Connect with database standing on host which requires SSH connection using Qt:

      Any ideas how to solve that?

      Use another port - you can't open a ssh tunnel on a port which is already in use.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • M Offline
        M Offline
        marcus74
        wrote on last edited by
        #8

        Still does not work.

        7fb6cd55-d396-4070-8514-e252aec6df47-obraz.png

        ssh -L 5000:localhost:22 userFromAboveHost@host.with.database.com
        

        have no effect too.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          Hi,

          @Christian-Ehrlicher suggested to change the port on your local host side to avoid the clash no the two. You can also disable temporarily your local PostgreSQL during the testing.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            @Christian-Ehrlicher suggested to change the port on your local host side to avoid the clash no the two. You can also disable temporarily your local PostgreSQL during the testing.

            M Offline
            M Offline
            marcus74
            wrote on last edited by
            #10

            @SGaist I've done it on screen and it didn't work as well

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #11

              @marcus74 said in Connect with database standing on host which requires SSH connection using Qt:

              I've done it on screen and it didn't work as well
              ssh -L 5000:localhost:22 userFromAboveHost@host.with.database.com

              No, you're now connecting to port 22 on your database server

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              M 1 Reply Last reply
              0
              • hskoglundH Offline
                hskoglundH Offline
                hskoglund
                wrote on last edited by
                #12

                The procedure is pretty good (and officially) documented by PostgreSQL

                1 Reply Last reply
                3
                • Christian EhrlicherC Christian Ehrlicher

                  @marcus74 said in Connect with database standing on host which requires SSH connection using Qt:

                  I've done it on screen and it didn't work as well
                  ssh -L 5000:localhost:22 userFromAboveHost@host.with.database.com

                  No, you're now connecting to port 22 on your database server

                  M Offline
                  M Offline
                  marcus74
                  wrote on last edited by
                  #13

                  @Christian-Ehrlicher On screen code I tried in second line:

                  ssh -L 5000:localhost:5432 userFromAboveHost@host.with.database.com
                  

                  and it gave above output.

                  1 Reply Last reply
                  0
                  • hskoglundH Offline
                    hskoglundH Offline
                    hskoglund
                    wrote on last edited by hskoglund
                    #14

                    Again hmm,, in the screenshot above you're using server.using.tunnel.com (not ```host.with.database.com``)?

                    Edit: I mean you should try this SSH:

                    ssh -L 5000:host.with.database.com:5432 userFromAboveServer@server.using.tunnel.com
                    
                    M 1 Reply Last reply
                    1
                    • hskoglundH hskoglund

                      Again hmm,, in the screenshot above you're using server.using.tunnel.com (not ```host.with.database.com``)?

                      Edit: I mean you should try this SSH:

                      ssh -L 5000:host.with.database.com:5432 userFromAboveServer@server.using.tunnel.com
                      
                      M Offline
                      M Offline
                      marcus74
                      wrote on last edited by
                      #15

                      @hskoglund Again, I receive errors about not accepting TCP/IP connections. Maybe I should pass by some way a password in process object for

                      userFromAboveServer@server.using.tunnel.com
                      

                      because in Windows cmd I am requested for password after doing this:

                      ssh -L 5000:host.with.database.com:5432 userFromAboveServer@server.using.tunnel.com
                      
                      1 Reply Last reply
                      0
                      • hskoglundH Offline
                        hskoglundH Offline
                        hskoglund
                        wrote on last edited by
                        #16

                        Yeah, if you're establishing the SSH tunnel via a command line, then there's no stable way to submit the password.
                        I think putty can be used in an automatic way, or, if you have a admin rights on server.using.tunnel.com you could create keys, so that no password is needed, more for example here

                        1 Reply Last reply
                        1
                        • M Offline
                          M Offline
                          marcus74
                          wrote on last edited by marcus74
                          #17

                          Ok, after long perturbations I used program:
                          https://geekflare.com/create-port-listener-in-windows-or-linux/
                          and created listening port 5000, then ran Qt project and everything is fine.
                          Thanks for all your patience :)

                          To conclude, passing passoword as I mentioned above is not mandatory.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved