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
- Log into your DigitalOcean account and click "Create Droplet"
- 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
- Open your terminal and navigate to SSH directory:
cd ~/.ssh
- Generate a new SSH key:
ssh-keygen
When prompted, save the key as id_NEWSERVERNAME
(replace NEWSERVERNAME with your server name)
Skip the passphrase by pressing Enter twice
Verify the key creation:
ls -l ~/.ssh
- Display your public key:
cat ~/.ssh/id_NEWSERVERNAME.pub
Copy the output and paste it into the "SSH KEY CONTENT" field on DigitalOcean
Fill in the hostname field with your server name
Click "Create Droplet"
2. Initial Server Configuration
First Login and Updates
- Log in as root using your SSH key
- Update the system:
sudo apt-get update && sudo apt-get dist-upgrade -y
User Account Setup
- Create a new user:
adduser USERNAMEOFYOURCHOICE
- Grant administrative privileges:
usermod -aG admin USERNAMEOFYOURCHOICE
usermod -aG sudo USERNAMEOFYOURCHOICE
Swap File Configuration
- Check current swap:
sudo swapon --show
- Create and configure swap file:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
- Make swap permanent by adding to fstab:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Essential Tools Installation
sudo apt install mc btop ncdu
System Reboot
sudo shutdown -r now
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\]\$ '
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
- Install essential build tools:
sudo apt install build-essential
- Configure Git:
git config --global user.email "YOUR.EMAIL@EXAMPLE.COM"
git config --global user.name "YOUR_GITHUB_USERNAME"
- Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
rustc --version
- Install additional development dependencies:
sudo apt install pkg-config xdg-utils httpie libssl-dev net-tools openssh-server \
debhelper-compat clang-tools libudev-dev
4. Security Configuration
Firewall Setup
- Configure UFW:
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw enable
SSH Configuration
-
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)
Top comments (0)