One place for hosting & domains

      Remote

      How To Set Up a Remote Desktop with X2Go on Ubuntu 18.04


      The author selected Software in the Public Interest (SPI) to receive a donation as part of the Write for DOnations program.

      Introduction

      Usually, Linux-based servers don’t come with a graphical user interface (GUI) pre-installed. Whenever you want to run GUI applications on your instance, the typical solution is to employ Virtual Network Computing (VNC). Unfortunately, VNC solutions can be sluggish and insecure; many also require a lot of manual configuration. By contrast, X2Go provides a working “cloud desktop,” complete with all the advantages of an always-online, remotely-accessible, and easily-scalable computing system with a fast network. It is also more responsive and more secure than many VNC solutions.

      In this tutorial, you’ll use X2Go to create an XFCE desktop environment that you can access remotely. This cloud desktop will include the same utilities that you would obtain had you installed Ubuntu 18.04 and the XFCE environment on your personal computer (almost identical to a Xubuntu setup).

      The setup described in this tutorial is useful when:

      • You need access to a Linux-based operating system, complete with a desktop environment, but can’t install it on your personal computer.
      • You use multiple devices in multiple locations and want a consistent work environment with the same tools, look, files, and performance.
      • Your Internet service provider gives you very little bandwidth, but you need access to tens or hundreds of gigabytes of data.
      • Long-running jobs make your local computer unavailable for hours or days. Imagine that you have to compile a large project, which will take 8 hours on your laptop. You won’t be able to watch movies or do anything else very resource-intensive while your project compiles. But if you run that job on your server, now your computer is free to perform other tasks.
      • You’re working with a team, and it benefits them to have a shared computer that they can access to collaborate on a project.

      Prerequisites

      Before starting this tutorial, you’ll need:

      • An Ubuntu 18.04 x64 instance with 2GB of RAM or more. 2GB is minimal, but a server with 4GB or more is ideal if you have memory-hungry applications that you plan to run. You can use a DigitalOcean Droplet if you like.

      • A user with sudo privileges and an SSH key. Follow this guide to get started: Initial Server Setup with Ubuntu 18.04. Make sure you complete Step 4 and configure your firewall to restrict all connections except for OpenSSH.

      Step 1 — Installing the Desktop Environment on Your Server

      With your server up and your firewall configured, you are now ready to install the graphical environment for the X2Go server.

      First, update the package manager’s information about the latest software available:

      In this tutorial, you are installing XFCE as the desktop environment. XFCE doesn’t use graphical effects like compositing, making it more compatible with X2Go and optimizing screen updates. For reference, the LXDE desktop environment and the MATE desktop environment (with compositing disabled) also work fine, but you’ll have to change the command in this tutorial where you install the desktop environment. For example, instead of sudo apt-get install xubuntu-desktop, you would type sudo apt-get install lubuntu-desktop to install LXDE.

      There are two ways to install XFCE; the Minimal Desktop Environment or the Full Desktop Environment. Choose just one of these two methods, described below.

      The Full Desktop Environment

      Recommended for most use cases. If you don’t want to handpick every component you need and would rather have a default set of packages, like a word processor, web browser, email client, and other accessories pre-installed, you can choose xubuntu-desktop.

      Install and configure the Full Desktop Environment. The Full Desktop Environment is similar to what you would get if you installed Xubuntu from a bootable DVD/USB memory stick to your local PC:

      • sudo apt-get install xubuntu-desktop

      You can now jump straight into the next step and install the X2Go server utilities.

      The Minimal Desktop Environment

      Alternately, if you want to install a small, core set of packages and then build on top of them by manually adding whatever you need, you can use the xubuntu-core meta-package.

      A meta-package doesn’t contain a single package; instead, a meta-package includes an entire package collection. Installing a meta-package saves the user from manually installing numerous components.

      Install xfce4 and all of the additional dependencies needed to support it:

      • sudo apt-get install xubuntu-core

      You have installed a graphical environment. Now you will establish a way to view it remotely.

      Step 2 — Installing X2Go on the Server

      X2Go comes with two main components: the server, which starts and manages the graphical session on the remote machine, and the client, which you install on your local computer to view and control the remote desktop or application.

      In previous versions of Ubuntu (before 18.04), x2goserver wasn’t included in the default repositories, so you’d have to follow steps like these to get the software package. We’re leaving the link here, just for reference, in case the package gets dropped in future versions of Ubuntu. Fortunately, Ubuntu 18.04, codenamed Bionic Beaver, includes the package you need in its default repositories, so the installation is faster.

      To install X2Go on your server, type the following command:

      • sudo apt-get install x2goserver x2goserver-xsession

      At this point, your server requires no further setup. However, keep in mind that if you followed the recommendation of setting up SSH keys in the Initial Server Setup with Ubuntu 18.04, then you will need to have your SSH private key available on every local machine that you intend to use. If you didn’t set up an SSH private key, make sure you choose a strong password.

      Note: Remember that if you run out of RAM, the Linux kernel might abruptly terminate some applications, resulting in lost work. If you are using a DigitalOcean Droplet and you notice that your programs require more RAM, you can temporarily power off your Droplet and upgrade (resize) to one with more memory.

      You have configured your server. Type exit or close your terminal window. The rest of the steps will focus on configuring the client on your local machine.

      Step 3 — Installing the X2Go Client Locally

      X2Go is ready to use out of the box. If you’re using Windows or Mac OS X on your local machine, you can download the X2Go client software here. If you’re using Debian or Ubuntu you can install the X2Go client with this command on your local machine:

      • sudo apt-get install x2goclient

      After downloading the software, you are ready to install it. Open the installer and select your preferred language. Now agree to the license and let the wizard guide you through the remaining steps. Typically, there shouldn’t be any reason to change the pre-filled, default values in these steps.

      X2Go works well out of the box, but it is also highly customizable. If you’d like additional information, visit X2Go’s official documentation.

      Now that you have installed the desktop client, you can configure its settings and connect to the X2Go server to use your remote XFCE desktop.

      Step 4 — Connecting To the Remote Desktop

      When you first open the X2Go client, a window will appear. If it doesn’t, click Session in the top-left menu and then select New session ….

      X2Go Client Screenshot - Creating a New Session

      In the Session name field, enter something to help differentiate between servers. Using a session name is particularly useful if you plan on connecting to multiple machines.

      Enter your server’s IP address or a fully qualified domain name (FQDN) in the Host field under Server.

      Enter the username you used for your SSH connection in the Login field.

      Since you installed XFCE in Step Two, choose XFCE as your Session type.

      Finally, because you connect to the server with SSH keys, click the folder icon next to Use RSA/DSA key for ssh connection and browse to your private key. If you didn’t opt to use the more secure SSH keys, leave this empty; the X2Go client will ask for a password each time you log in.

      The rest of the default settings will suffice for now, but as you get more familiar with the software, you can fine-tune the client based on your individual preferences.

      After pressing the OK button, you can start your graphical session by clicking the white box that includes your session’s name on the box’s top-right side.

      X2Go Main Window - Session List

      If you are running OS X on your local machine, OS X might prompt you to install XQuartz, which is required to run X11. If so, follow the instructions to install it now.

      In a few seconds, your remote desktop will appear, and you can start interacting with it.

      There are a few useful keyboard shortcuts you can use for a better experience on Windows and Linux-based operating systems.

      Note: These first two options can exhibit buggy behavior on modern Windows editions. You can still test them at this point, in case later versions of X2Go fix the issues. If they fail, just avoid using the same keyboard shortcut in the future.

      CTRL+ALT+F will toggle full-screen mode on and off. Working in full-screen mode can feel more like a local desktop experience. The full-screen mode also helps the remote machine grab keyboard shortcuts instead of your local machine.

      CTRL+ALT+M will minimize the remote view, even if you are in full-screen mode.

      CTRL+ALT+T will disconnect from the session but leave the GUI running on the server. It’s just a quick way of disconnecting without logging off or closing applications on the server. The same will happen if you click the window’s close button.

      Lastly, there are two ways you can end the remote session and close all of the graphical programs running in it. You can log off remotely from XFCE’s start menu, or you can click the button marked with a circle and a small line (like a power/standby icon) in the bottom-right corner of the main portion of the X2Go screen.

      The first method is cleaner but may leave programs like session-managing software running. The second method will close everything but may do so forcefully if a process can’t exit cleanly. In either case, be sure to save your work before proceeding.

      X2Go Main Window - Terminate Session Button

      You have now successfully accessed and configured your remote desktop.

      Conclusion

      In this tutorial, you used X2Go to create a robust and remote GUI-environment for the Ubuntu operating system. Now that you are up and running, here are a few ideas about using this desktop:

      If you’d like to learn more, visit X2Go’s official documentation website.



      Source link

      How To Set Up a Remote Desktop with X2Go on CentOS 8


      The author selected Software in the Public Interest (SPI) to receive a donation as part of the Write for DOnations program.

      Introduction

      Usually, Linux-based servers don’t come with a graphical user interface (GUI) pre-installed. Whenever you want to run GUI applications on your instance, the typical solution is to employ Virtual Network Computing (VNC). Unfortunately, VNC solutions can be sluggish and insecure; many also require a lot of manual configuration. By contrast, X2Go provides a working “cloud desktop,” complete with all the advantages of an always-online, remotely-accessible, and easily-scalable computing system with a fast network. It is also more responsive and more secure than many VNC solutions.

      In this tutorial, you’ll use X2Go to create an XFCE desktop environment that you can access remotely.

      The setup described in this tutorial is useful when:

      • You need access to a Linux-based operating system, complete with a desktop environment, but can’t install it on your personal computer.
      • You use multiple devices in multiple locations (e.g., personal laptop, work laptop) but want a persistent work environment that has the same tools, look, files, and performance. Imagine a scenario where you forget to take your work laptop with you, or it malfunctions and you have to send it for repair. Since everything on a remote desktop stays the same, you don’t have to reinstall the whole suite of utilities you like to use to do your job. You just log in to the remote desktop and everything will be there, exactly as you left it, no matter what device you are logging in from.
      • Your Internet service provider gives you very little bandwidth, but you need access to tens or hundreds of gigabytes of data. For example, you can download 100GB of data, taking advantage of the server’s very fast network. Since the server itself is the one using bandwidth you don’t use the quota your Internet Service Provider allocates to you monthly. You only pay for the network bandwidth required to send you images of your remote desktop, which is very small, in comparison.
      • Long-running jobs make your local computer unavailable for hours or days. Imagine that you have to compile a large project, which will take 8 hours on your laptop. You won’t be able to watch movies or do anything else very resource-intensive while your project compiles. But if you run that job on your server, now your computer is free to perform other tasks.
      • You’re working with a team, and it benefits all members to have a common, shared computer that they can access to collaborate on a project.

      Prerequisites

      Before starting this tutorial, you’ll need:

      • A CentOS 8 x64 instance with 2GB of RAM or more. 2GB is minimal, but a server with 4GB or more is ideal if you have memory-hungry applications that you plan to run. You can use a DigitalOcean Droplet if you like.

      • A user with sudo privileges and an SSH key. Follow this guide to get started: Initial Server Setup with CentOS 8. At Step 4, configure the firewall as instructed, but don’t enter the command firewall-cmd --permanent --add-service=http. This command opens post 80 on your server, which you don’t need.

      Step 1 — Installing the Desktop Environment on Your Server

      With your server up and your firewall configured, you are now ready to install the graphical environment.

      First, upgrade all software packages on your instance:

      In this tutorial, you are installing XFCE as the desktop environment. XFCE doesn’t use graphical effects like compositing, making it more compatible with X2Go and allowing it to optimize how screen updates are sent across the network. In other words, it’s probably the easiest one to get working with X2Go since everything immediately works well out of the box. LXDE should also work out of the box. MATE and KDE desktop environments might work too, but some workarounds might be needed, for example, disabling compositing to improve performance and responsiveness.

      If you prefer a different desktop environment, you would have to replace a command such as sudo dnf groupinstall Xfce from this tutorial with sudo dnf group install "KDE Plasma Workspaces" to install KDE, and then configure the Session type in your X2Go client to KDE. You can also install multiple desktop environments, alongside each other, and then pick the one you prefer to launch, each time you log in with your X2Go client.

      The software packages you now need to install aren’t contained in CentOS’ default repositories, so you have to enable the Extra Packages for Enterprise Linux (EPEL) repositories:

      • sudo dnf install epel-release

      Some X2Go server utilities also depend on some packages found in the PowerTools repository, which you can enable with the next command:

      • sudo dnf config-manager --set-enabled PowerTools

      Finally, you can now install the XFCE desktop environment:

      • sudo dnf groupinstall Xfce

      CentOS offers a rather minimal XFCE environment, but you can add any other utilities you need (e.g., web browsers, image editors) with simple sudo dnf install name_of_application commands.

      With the desktop environment now installed, it’s time to establish a way to view it on your local computer.

      Step 2 — Installing X2Go on the Server

      X2Go comes with two main components: the server, which starts and manages the graphical session on the remote machine, and the client, which you install on your local computer to view and control the remote desktop or application.

      To install X2Go on your server, type the following command:

      • sudo dnf install x2goserver

      At this point, your server requires no further setup. However, keep in mind that if you followed the recommendation of setting up SSH keys in the Initial Server Setup with CentOS 8, then you will need to have your SSH private key available on every local machine that you intend to log in from, to your remote desktop session. If you didn’t set up an SSH private key, make sure you choose a strong password.

      Note: Remember that if you run out of RAM, the Linux kernel might abruptly terminate some applications, resulting in lost work. If you are using a DigitalOcean Droplet and you notice that your programs require more RAM, you can temporarily power off your Droplet and upgrade (resize) to one with more memory.

      You have configured your server. Type exit or close your terminal window. The rest of the steps will focus on configuring the client on your local machine.

      Step 3 — Installing the X2Go Client Locally

      X2Go is ready to use out of the box. If you’re using Windows or macOS on your local machine, you can download the X2Go client software here. If you’re using Debian or Ubuntu you can install the X2Go client with this command on your local machine:

      • sudo apt-get install x2goclient

      After downloading the software, you are ready to install it. Open the installer and select your preferred language. Now agree to the license and let the wizard guide you through the remaining steps. Typically, there shouldn’t be any reason to change the pre-filled, default values in these steps.

      X2Go works well out of the box, but it is also highly customizable. If you’d like additional information, visit X2Go’s official documentation.

      Now that you have installed the desktop client, you can configure its settings and connect to the X2Go server to use your remote XFCE desktop.

      Step 4 — Connecting To the Remote Desktop

      When you first open the X2Go client, a window will appear. If it doesn’t, click Session in the top-left menu and then select New session ….

      X2Go Client Screenshot - Creating a New Session

      In the Session name field, enter something to help differentiate between servers. Using a session name is particularly useful if you plan on connecting to multiple machines.

      Enter your server’s IP address or a fully qualified domain name (FQDN) in the Host field under Server.

      Enter the username you used for your SSH connection in the Login field.

      Since you installed XFCE in Step Two, choose XFCE as your Session type.

      Finally, because you connect to the server with SSH keys, click the folder icon next to Use RSA/DSA key for ssh connection and browse to your private key. If you didn’t opt to use the more secure SSH keys, leave this empty; the X2Go client will ask for a password each time you log in.

      The rest of the default settings will suffice for now, but as you get more familiar with the software, you can fine-tune the client based on your individual preferences.

      After pressing the OK button, you can start your graphical session by clicking the white box that includes your session’s name on the box’s top-right side.

      X2Go Main Window - Session List

      If you are running OS X on your local machine, OS X might prompt you to install XQuartz, which is required to run X11. If so, follow the instructions to install it now.

      In a few seconds, your remote desktop will appear, and you can start interacting with it.

      There are a few useful keyboard shortcuts you can use for a better experience on Windows and Linux-based operating systems.

      Note: These first two options can exhibit buggy behavior on modern Windows editions. You can still test them at this point, in case later versions of X2Go fix the issues. If they fail, just avoid using the same keyboard shortcut in the future.

      CTRL+ALT+F will toggle full-screen mode on and off. Working in full-screen mode can feel more like a local desktop experience. The full-screen mode also helps the remote machine grab keyboard shortcuts instead of your local machine.

      CTRL+ALT+M will minimize the remote view, even if you are in full-screen mode.

      CTRL+ALT+T will disconnect from the session but leave the GUI running on the server. It’s just a quick way of disconnecting without logging off or closing applications on the server. The same will happen if you click the window’s close button.

      Lastly, there are two ways you can end the remote session and close all of the graphical programs running in it. You can log off remotely from XFCE’s start menu, or you can click the button marked with a circle and a small line (like a power/standby icon) in the bottom-right corner of the main portion of the X2Go screen.

      The first method is cleaner but may leave programs like session-managing software running. The second method will close everything but may do so forcefully if a process can’t exit cleanly. In either case, be sure to save your work before proceeding.

      X2Go Main Window - Terminate Session Button

      You have now successfully accessed and configured your remote desktop.

      Conclusion

      In this tutorial, you used X2Go to create a robust and remote GUI-environment for the CentOS operating system. Now that you are up and running, here are a few ideas about using this desktop:

      • You could centralize your development work by creating a git repository.
      • You could install an IDE/code editor like NetBeans or Eclipse. You could also use Visual Studio Code for remote development via the Remote-SSH Plugin.
      • You could configure a web server for testing web applications. By opening up a browser on your remote desktop, and navigating to localhost in the address bar, you can test the web application you are working on, without having to constantly re-upload files to some remote server. And everything is encapsulated within the secure and private SSH connection used by X2Go to view your remote desktop. This means that although you are testing your website on a server connected to the Internet, the web app you are working on can only be viewed by you, it is not publicly accessible, so you don’t have to worry about accidentally leaking unfinished and unpolished work.
      • You could also enhance your remote desktop with a good backup scheme to preserve your work environment and essential data in case something ever goes wrong. With DigitalOcean, you can also snapshot your Droplets when you’re happy with a particular setup. This way, you can test risky changes and quickly come back to a known, working state, if it’s ever required, something that is not so easy to do on a typical Windows computer. Snapshots also allow you to clone a particular setup. This would make it possible to give all team members their own, private, remote desktops, where they can perform work in similar environments, as far as development tools are concerned. But this way, they would each be able to customize their environment as they like, and work with their own sets of files.

      All in all, you can create a complete development environment, with all the bells and whistles, from the code editor you use, to the software required to run and test that code.

      If you’d like to learn more, visit X2Go’s official documentation website.



      Source link

      How To Configure Remote Access for MongoDB on Ubuntu 18.04


      An earlier version of this tutorial was written by Melissa Anderson.

      Introduction

      MongoDB, also known as Mongo, is an open-source document database used commonly in modern web applications. By default, it only allows connections that originate on the same server where it’s installed. If you want to manage MongoDB remotely or connect it to a separate application server, there are a few changes you’d need to make to the default configuration.

      In this tutorial, you will configure a MongoDB installation to securely allow access from a trusted remote computer. To do this, you’ll update your firewall rules to provide the remote machine access to the port on which MongoDB is listening for connections and then update its configuration file to change its IP binding setting. Then, as a final step, you’ll test that your remote machine is able to make the connection to your database successfully.

      Prerequisites

      To complete this tutorial, you’ll need:

      • A server running Ubuntu 18.04. This server should have a non-root administrative user and a firewall configured with UFW. Set this up by following our initial server setup guide for Ubuntu 18.04.
      • MongoDB installed on your server. This tutorial assumes that you have MongoDB 4.4 or newer installed. You can install this version by following our tutorial on How To Install MongoDB on Ubuntu 18.04.
      • A second computer from which you’ll access your MongoDB instance. For simplicity, this tutorial assumes that this machine is another Ubuntu 18.04 server, with a non-root administrative user and a UFW firewall configured following our initial server setup guide for Ubuntu 18.04. However, Steps 1 and 2, which describe the actual procedure for enabling remote connectivity on the database server, will work regardless of what operating system the remote machine is running.

      Lastly, while it isn’t required to complete this tutorial, we strongly recommend that you secure your MongoDB installation by creating an administrative user account for the database and enabling authentication. To do this, follow our tutorial on How To Secure MongoDB on Ubuntu 18.04.

      Step 1 — Adjusting the Firewall

      Assuming you followed the prerequisite initial server setup tutorial and enabled a UFW firewall on your server, your MongoDB installation will be inaccessible from the internet. If you intend to use MongoDB only locally with applications running on the same server, this is the recommended and secure setting. However, if you would like to be able to connect to your MongoDB server from a remote location, you have to allow incoming connections to the port where the database is listening by adding a new UFW rule.

      Start by checking which port your MongoDB installation is listening on with the lsof command. This command typically returns a list with every open file in a system, but when combined with the -i option, it lists only network-related files or data streams.

      The following command will redirect the output produced by lsof -i to a grep command that searches for a string named mongo:

      • sudo lsof -i | grep mongo

      This example output shows that the mongod process is listening for connections on its default port, 27017:

      Output

      . . . mongod 82221 mongodb 11u IPv4 913411 0t0 TCP localhost:27017 (LISTEN) . . .

      In most cases, MongoDB should only be accessed from certain trusted locations, such as another server hosting an application. One way to configure this is to run the following command on your MongoDB server, which opens up access on MongoDB’s default port while explicitly only allowing the IP address of the other trusted server.

      Run the following command, making sure to change trusted_server_ip to the IP address of the trusted remote machine you’ll use to access your MongoDB instance:

      Note: If the previous command’s output showed your installation of MongoDB is listening on a non default port, use that port number in place of 27017 in this command.

      • sudo ufw allow from trusted_server_ip to any port 27017

      In the future, if you ever want to access MongoDB from another machine, run this command again with the new machine’s IP address in place of trusted_server_ip.

      You can verify the change in firewall settings with ufw:

      The output will show that traffic to port 27017 from the remote server is now allowed:

      Output

      Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere 27017 ALLOW trusted_server_ip OpenSSH (v6) ALLOW Anywhere (v6)

      You can find more advanced firewall settings for restricting access to services in UFW Essentials: Common Firewall Rules and Commands.

      Next, you’ll bind MongoDB to the server’s public IP address so you can access it from your remote machine.

      Step 2 — Configuring a Public bindIP

      At this point, even though the port is open, MongoDB is currently bound to 127.0.0.1, the local loopback network interface. This means that MongoDB is only able to accept connections that originate on the server where it’s installed.

      To allow remote connections, you must edit the MongoDB configuration file — /etc/mongod.conf — to additionally bind MongoDB to your server’s publicly-routable IP address. This way, your MongoDB installation will be able to listen to connections made to your MongoDB server from remote machines.

      Open the MongoDB configuration file in your preferred text editor. The following example uses nano:

      • sudo nano /etc/mongod.conf

      Find the network interfaces section, then the bindIp value:

      /etc/mongod.conf

      . . .
      # network interfaces
      net:
        port: 27017
        bindIp: 127.0.0.1
      
      . . .
      

      Append a comma to this line followed by your MongoDB server’s public IP address:

      /etc/mongod.conf

      . . .
      # network interfaces
      net:
        port: 27017
        bindIp: 127.0.0.1,mongodb_server_ip
      
      . . .
      

      Save and close the file. If you used nano, do so by pressing CTRL + X, Y, then ENTER.

      Then, restart MongoDB to put this change into effect:

      • sudo systemctl restart mongod

      Following that, your MongoDB installation will be able to accept remote connections from whatever machines you’ve allowed to access port 27017. As a final step, you can test whether the trusted remote server you allowed through the firewall in Step 1 can reach the MongoDB instance running on your server.

      Step 3 — Testing Remote Connectivity

      Now that you configured your MongoDB installation to listen for connections that originate on its publicly-routable IP address and granted your remote machine access through your server’s firewall to Mongo’s default port, you can test that the remote machine is able to connect.

      Note: As mentioned in the Prerequisites section, this tutorial assumes that your remote machine is another server running Ubuntu 18.04. The procedure for enabling remote connections outlined in Steps 1 and 2 should work regardless of what operating system your remote machine runs, but the testing methods described in this Step do not work universally across operating systems.

      One way to test that your trusted remote server is able to connect to the MongoDB instance is to use the nc command. nc, short for netcat, is a utility used to establish network connections with TCP or UDP. It’s useful for testing in cases like this because it allows you to specify both an IP address and a port number.

      First, log into your trusted server using SSH:

      • ssh sammy@trusted_server_ip

      Then run the following nc command, which includes the -z option. This limits nc to only scan for a listening daemon on the target server without sending it any data. Recall from the prerequisite installation tutorial that MongoDB is running as a service daemon, making this option useful for testing connectivity. It also includes the v option which increases the command’s verbosity, causing netcat to return some output which it otherwise wouldn’t.

      Run the following nc command from your trusted remote server, making sure to replace mongodb_server_ip with the IP address of the server on which you installed MongoDB:

      • nc -zv mongodb_server_ip 27017

      If the trusted server can access the MongoDB daemon, its output will indicate that the connection was successful:

      Output

      Connection to mongodb_server_ip 27017 port [tcp/*] succeeded!

      Assuming you have a compatible version of the mongo shell installed on your remote server, you can at this point connect directly to the MongoDB instance installed on the host server.

      One way to connect is with a connection string URI, like this:

      • mongo "mongodb://mongo_server_ip:27017"

      Note: If you followed the recommended How To Secure MongoDB on Ubuntu 18.04 tutorial, you will have closed off access to your database to unauthenticated users. In this case, you’d need to use a URI that specifies a valid username, like this:

      • mongo "mongodb://username@mongo_server_ip:27017"

      The shell will automatically prompt you to enter the user’s password.

      With that, you’ve confirmed that your MongoDB server can accept connections from the trusted server.

      Conclusion

      You can now access your MongoDB installation from a remote server. At this point, you can manage your Mongo database remotely from the trusted server. Alternatively, you could configure an application to run on the trusted server and use the database remotely.

      If you haven’t configured an administrative user and enabled authentication, anyone who has access to your remote server can also access your MongoDB installation. If you haven’t already done so, we strongly recommend that you follow our guide on How To Secure MongoDB on Ubuntu 18.04 to add an administrative user and lock things down further.



      Source link