Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-9816

Add clarification/troubleshoot for SSH Tunnel feature in Compass

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Compass
    • Labels:
      None
    • # Replies:
      0
    • Last comment by Customer:
      true
    • Sprint:
      KANBAN BUCKET

      Description

      We should mention the following in the documentation on the connect page:

      https://docs.mongodb.com/compass/current/connect/

      SSH tunnel troubleshoot

      If you want to connect to a MongoDB instance via an SSH tunnel through a bastion host, the ssh configuration on the bastion host must allow TCP port forwarding. This can be enabled in the /etc/ssh/sshd_config file by setting the AllowTcpForwarding directive to yes, and restarting the the ssh daemon (sudo service sshd restart).

      Some distributions have this mode enabled by default, others do not.

      Also ensure that the bastion (jumpbox) hostname goes into the "SSH Hostname" field, and your final destination database hostname goes into the "Hostname" field at the top.

      Manually set up SSH tunnel

      You can also manually build an SSH tunnel from the command line with the following command:

      ssh -L <local_port>:<mongodb_hostname>:<mongodb_port> <user>@<bastion_hostname> -fN
      

      For example, if you have a mongod server running on (internal) hostname-a.com on port 27017, and the bastion host is hostname-b.com with user name ec2-user, you can build the tunnel via

      ssh -L 27000:hostname-a.com:27017 ec2-user@hostname-b.com -fN
      

      You can now connect the mongo shell or Compass locally on localhost:27000 to connect to that remote server via the SSH tunnel.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                3 years, 10 weeks, 1 day ago
                Date of 1st Reply: