DEV Community

Cover image for Creating a new Developer Server in Digital Ocean
rodit-org
rodit-org

Posted on • Edited on

Creating a new Developer Server in Digital Ocean

This guide will walk you through the process step by step, from creating your droplet to adding some essential development tools for Rust and Javascript.

Note: Picture by Christopher Gower's

Prerequisites

  • A DigitalOcean account
  • Basic command line knowledge
  • SSH client installed on your local machine

1. Creating Your Droplet

Initial Setup

  1. Log into your DigitalOcean account and click "Create Droplet"
  2. Choose your region
    • Note: All resources in this datacenter will be part of the same VPC network
    • They can communicate securely over their Private IP addresses

Configuration

  • Select Ubuntu (latest version)
  • Choose NVMe SSD for storage
  • Select the basic plan:
    • 2GB RAM
    • 25GB Disk
    • 1TB transfer
    • Approximately $12/month

SSH Key Setup

  1. Open your terminal and navigate to SSH directory:
   cd ~/.ssh
Enter fullscreen mode Exit fullscreen mode
  1. Generate a new SSH key:
   ssh-keygen
Enter fullscreen mode Exit fullscreen mode

When prompted, save the key as id_NEWSERVERNAME (replace NEWSERVERNAME with your server name)

  1. Skip the passphrase by pressing Enter twice

  2. Verify the key creation:

   ls -l ~/.ssh
Enter fullscreen mode Exit fullscreen mode
  1. Display your public key:
   cat ~/.ssh/id_NEWSERVERNAME.pub
Enter fullscreen mode Exit fullscreen mode
  1. Copy the output and paste it into the "SSH KEY CONTENT" field on DigitalOcean

  2. Fill in the hostname field with your server name

  3. Click "Create Droplet"

2. Initial Server Configuration

First Login and Updates

  1. Log in as root using your SSH key
  2. Update the system:
   sudo apt-get update && sudo apt-get dist-upgrade -y
Enter fullscreen mode Exit fullscreen mode

User Account Setup

  1. Create a new user:
   adduser USERNAMEOFYOURCHOICE
Enter fullscreen mode Exit fullscreen mode
  1. Grant administrative privileges:
   usermod -aG admin USERNAMEOFYOURCHOICE
   usermod -aG sudo USERNAMEOFYOURCHOICE
Enter fullscreen mode Exit fullscreen mode

Swap File Configuration

  1. Check current swap:
   sudo swapon --show
Enter fullscreen mode Exit fullscreen mode
  1. Create and configure swap file:
   sudo fallocate -l 1G /swapfile
   sudo chmod 600 /swapfile
   sudo mkswap /swapfile
   sudo swapon /swapfile
Enter fullscreen mode Exit fullscreen mode
  1. Make swap permanent by adding to fstab:
   echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Enter fullscreen mode Exit fullscreen mode

Essential Tools Installation

sudo apt install mc btop ncdu
Enter fullscreen mode Exit fullscreen mode

System Reboot

sudo shutdown -r now
Enter fullscreen mode Exit fullscreen mode

3. Development Environment Setup

Bash Customization

Login as your new user and edit ~/.bashrc:

force_color_prompt=yes
PS1='${debian_chroot:+($debian_chroot)}\[\033[0;36m\]\u@\h\[\033[00m\]:\[\033[0;34m\]\w\[\033[00m\]\$ '
Enter fullscreen mode Exit fullscreen mode

Available colors:

  • Black: \[\033[0;30m\]
  • Red: \[\033[0;31m\]
  • Green: \[\033[0;32m\]
  • Yellow: \[\033[0;33m\]
  • Blue: \[\033[0;34m\]
  • Magenta: \[\033[0;35m\]
  • Cyan: \[\033[0;36m\]
  • White: \[\033[0;37m\]

Development Tools Installation

  1. Install essential build tools:
   sudo apt install build-essential
Enter fullscreen mode Exit fullscreen mode
  1. Configure Git:
   git config --global user.email "YOUR.EMAIL@EXAMPLE.COM"
   git config --global user.name "YOUR_GITHUB_USERNAME"
Enter fullscreen mode Exit fullscreen mode
  1. Install Rust:
   curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
   source "$HOME/.cargo/env"
   rustc --version
Enter fullscreen mode Exit fullscreen mode
  1. Install additional development dependencies:
   sudo apt install pkg-config xdg-utils httpie libssl-dev net-tools openssh-server \
   debhelper-compat clang-tools libudev-dev
Enter fullscreen mode Exit fullscreen mode

4. Security Configuration

Firewall Setup

  1. Configure UFW:
   sudo ufw allow 22/tcp
   sudo ufw allow 443/tcp
   sudo ufw enable
Enter fullscreen mode Exit fullscreen mode

SSH Configuration

  1. Set up SSH access:

    • On your local machine:
     cat ~/.ssh/id_NEWSERVERNAME.pub
    
  • Copy the output and add it to ~/.ssh/authorized_keys on the server

Conclusion

Your development server is now ready for use! You have a secure, well-configured environment with essential development tools installed. The server includes:

  • A non-root user with sudo privileges
  • Configured swap space
  • Essential development tools and utilities
  • Basic security settings with UFW
  • Rust programming environment
  • Various development dependencies

Remember to regularly update your system and monitor resource usage with the installed tools (btop, ncdu).

If you use Visual Code, for example you can now configure your IDE following these instructions: (https://code.visualstudio.com/docs/remote/ssh?WT.mc_id=netbc-meetup-antchu)

Additional Resources

Top comments (0)