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

Add clarification/troubleshoot for SSH Tunnel feature in Compass

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • Affects Version/s: None
    • Component/s: Compass
    • Labels:
      None

      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.

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              7 years, 14 weeks, 1 day ago