Installing Cloudflared on DigitalOcean Ubuntu
Tags: webdev, javascript, beginners, programming
Published: 2024-07-06 09:28:05

### Installing Cloudflared on DigitalOcean Ubuntu

Cloudflared is a tunneling daemon that allows you to securely connect your server to Cloudflare's network without exposing your origin server to the internet. This guide will walk you through the steps to install Cloudflared on an Ubuntu server hosted on DigitalOcean.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jzc46dw7rytih7r3wopl.png)



#### Prerequisites
- An Ubuntu server on DigitalOcean
- SSH access to the server
- Basic knowledge of command line operations

#### Step 1: Update Your System
Start by updating your package lists and upgrading existing packages to ensure everything is up to date.

```bash
sudo apt update
sudo apt upgrade -y
```

#### Step 2: Install Required Packages
Install the necessary packages to add the Cloudflare repository.

```bash
sudo apt install curl lsb-release
```

#### Step 3: Add the Cloudflare GPG Key and Repository
Add the Cloudflare GPG key and repository to your system.

```bash
curl -L https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-archive-keyring.gpg >/dev/null
```

Since the `noble` release does not have a repository, you can use the `focal` release which is often supported.

```bash
echo "deb [signed-by=/usr/share/keyrings/cloudflare-archive-keyring.gpg] https://pkg.cloudflare.com/cloudflared focal main" | sudo tee /etc/apt/sources.list.d/cloudflared.list
```

#### Step 4: Update Package List Again
Update the package list to include the new Cloudflare repository.

```bash
sudo apt update
```

#### Step 5: Install Cloudflared
Install the Cloudflared package.

```bash
sudo apt install cloudflared
```

#### Alternative Method: Using Snap
If you prefer using Snap to manage your packages, you can install Cloudflared via Snap. Ensure Snap is installed and then install Cloudflared.

1. **Ensure Snap is installed**:
    ```bash
    sudo apt update
    sudo apt install snapd
    sudo snap install core
    ```

2. **Install Cloudflared via Snap**:
    ```bash
    sudo snap install jnsgruk-cloudflared
    ```

#### Step 6: Ensure Cloudflared is in Your PATH
If the `cloudflared` command is not found, add Snap's binary path to your system's `PATH`.

```bash
echo 'export PATH=$PATH:/snap/bin' >> ~/.bashrc
source ~/.bashrc
```

#### Step 7: Verify Installation
Verify that Cloudflared is correctly installed by checking its version.

```bash
which cloudflared
cloudflared --version
```

If everything is set up correctly, you should see the path to the `cloudflared` binary and its version information.

#### Conclusion
By following these steps, you can install Cloudflared on your DigitalOcean Ubuntu server, allowing you to securely connect your server to Cloudflare's network. This setup helps enhance your server's security by keeping it hidden from the public internet.

For more detailed information and troubleshooting, you can refer to the official [Cloudflare documentation](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation).

---

**References:**
- [Cloudflare Docs](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation)
- [Snapcraft: Install Cloudflared on Ubuntu](https://snapcraft.io/install/jnsgruk-cloudflared/ubuntu)
- [Pi My Life Up: Install Cloudflared on Ubuntu](https://pimylifeup.com/cloudflared-ubuntu/)