Secure Remote Access to DigitalOcean with Netmaker

Securing remote access to your DigitalOcean droplet with Netmaker can significantly enhance the security and management of your network. Netmaker is an open-source network management solution that allows you to create secure, scalable, and high-performance virtual private networks (VPNs) using WireGuard. Below is a step-by-step guide to setting up Netmaker to secure remote access to your DigitalOcean droplets:

Step 1: Set Up a DigitalOcean Droplet for Netmaker
  1. Create a Droplet:
    • Log in to your DigitalOcean account.
    • Create a new droplet using Ubuntu 22.04 LTS.
    • Choose a droplet size appropriate for your needs (2GB RAM is a good starting point).
    • Add your SSH key for secure access.
    • Choose a data center region.
    • Click "Create Droplet".
  2. Access Your Droplet:
    • Open a terminal on your local machine.
    • Connect to your droplet using its IP address:

                          
                              ssh root@your_droplet_ip
                          
                      

Step 2: Install Docker and Docker Compose
  1. Update Your System:

                    
                        sudo apt update
                        sudo apt upgrade -y                    
                    
                

  2. Install Docker:

                    
                        sudo apt install -y docker.io
                        sudo systemctl start docker
                        sudo systemctl enable docker                    
                    
                

  3. Install Docker Compose:

                    
                        sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
                        sudo chmod +x /usr/local/bin/docker-compose                    
                    
                

Step 3: Set Up Netmaker
  1. Clone the Netmaker Repository:

                    
                        git clone https://github.com/gravitl/netmaker.git
                        cd netmaker                    
                    
                

  2. Configure Environment Variables:
    • Create an .env file in the root of the netmaker directory and populate it with the necessary environment variables:
    •                     
                              nano .env
                          
                      

  3. Example .env configuration:

                    
                        SERVER_NAME=netmaker
                        SERVER_IP=your_droplet_ip
                        SERVER_PORT=443
                        API_PORT=8081
                        DASHBOARD_PORT=8082
                        MQ_USERNAME=netmaker
                        MQ_PASSWORD=changeme                    
                    
                

  4. Start Netmaker with Docker Compose:

                    
                        sudo docker-compose up -d
                    
                

Step 4: Configure WireGuard on Your Local Machine
  1. Install WireGuard:
    • On Ubuntu:

                              
                                  sudo apt install wireguard
                              
                          

    • On macOS:

                              
                                  brew install wireguard-tools
                              
                          

    • On Windows:

      Download and install WireGuard from the official website.

  2. Generate WireGuard Keys:

                    
                        wg genkey | tee privatekey | wg pubkey > publickey
                    
                

  3. Configure WireGuard Client:
    • Create a configuration file (e.g., wg0.conf):
  4. Example wg0.conf:

                    
                        [Interface]
                        PrivateKey = your_private_key
                        Address = 10.0.0.2/24
                        DNS = 1.1.1.1
                        
                        [Peer]
                        PublicKey = server_public_key
                        Endpoint = your_droplet_ip:51820
                        AllowedIPs = 0.0.0.0/0
                        PersistentKeepalive = 21                    
                    
                

  5. Start WireGuard:
    • On Ubuntu/macOS:

                              
                                  sudo wg-quick up wg0
                              
                          

    • On Windows:
      • Import the wg0.conf file into the WireGuard application and activate the tunnel.
Step 5: Access and Manage Your Network
  1. Access Netmaker Dashboard:
    • Open a web browser and navigate to https://your_droplet_ip:8082.
    • Log in with the default credentials or the ones you configured.
  2. Add Machines to the Network:
    • Use the Netmaker dashboard to add new nodes (machines) to your WireGuard network.
    • Follow the instructions provided in the Netmaker documentation to securely connect additional devices.
Step 6: Secure Your Netmaker Deployment
  1. Enable UFW Firewall:

                    
                        sudo ufw allow OpenSSH
                        sudo ufw allow 443/tcp
                        sudo ufw allow 51820/udp
                        sudo ufw enable                    
                    
                

  2. Set Up SSL with Let’s Encrypt:
    • Install Certbot:

                              
                                  sudo apt install certbot
                                  sudo apt install python3-certbot-nginx                            
                              
                          

    • Obtain an SSL certificate:

                              
                                  sudo certbot --nginx -d your_domain  
                              
                          

  3. Configure Nginx for SSL:
    • Edit the Nginx configuration to use the obtained SSL certificate:
    •                     
                              sudo nano /etc/nginx/sites-available/default
                          
                      

    • Ensure the configuration includes:

                              
                                  server {
                                      listen 443 ssl;
                                      server_name your_domain;
                                  
                                      ssl_certificate /etc/letsencrypt/live/your_domain/fullchain.pem;
                                      ssl_certificate_key /etc/letsencrypt/live/your_domain/privkey.pem;
                                  
                                      location / {
                                          proxy_pass http://localhost:8082;
                                          proxy_set_header Host $host;
                                          proxy_set_header X-Real-IP $remote_addr;
                                          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                          proxy_set_header X-Forwarded-Proto $scheme;
                                      }
                                  }                             
                              
                          

  4. Restart Nginx:

                    
                        sudo systemctl restart nginx
                    
                

By following these steps, you will have set up a secure remote access network using Netmaker on DigitalOcean. This will enable you to manage and secure your droplets and other connected devices with ease.

Video Streaming on Premium CPU-Optimized Droplets

Setting up video streaming on DigitalOcean’s premium CPU-optimized droplets can offer high performance for encoding, streaming, and handling multiple simultaneous connections. Below is a step-by-step guide to deploy a video streaming server usi …

read more

Streamline Deployment through CI/CD on DigitalOcean's App Platform

To streamline the deployment of Ghost CMS using Continuous Integration and Continuous Deployment (CI/CD) on DigitalOcean's App Platform, you can follow these steps. This guide assumes you have some basic understanding of Git, CI/CD concepts, and the …

read more