How to set up a DigitalOcean VPS for AI
Get your own server online and log in with an SSH key.
A place to run your tools without relying on your laptop. Start with a fresh learning server, not an existing business system.
Before you start
- A DigitalOcean account you control and a cloud budget you have approved.
- A macOS, Linux or WSL Bash terminal, plus your current public IPv4 address.
- This path uses a fresh Ubuntu 24.04 LTS x86_64 Droplet. Choose capacity for the applications you actually plan to run.
Check the live plan and add-on prices before creating anything. Powering off a Droplet does not end its charges.
Setup steps
Create an SSH key
Where: Your computer / Bash terminal
This example uses a new key named campus_do. If either file already exists, do not overwrite it: verify the existing pair or choose another name and update later commands. Choose a passphrase when prompted. Only the .pub file goes to DigitalOcean.
mkdir -p ~/.ssh if [ -e ~/.ssh/campus_do ] || [ -e ~/.ssh/campus_do.pub ]; then printf '%s\n' 'Key file exists. Verify its pair or choose another name.' else ssh-keygen -t ed25519 -f ~/.ssh/campus_do -C open-campus fiCheck: You have a matching private key and public .pub file. The private key stays on your computer.
Add the public key
Where: Your computer, then DigitalOcean / Settings → Security
Display the public key below, then add that public text in DigitalOcean’s SSH Keys section. Keep the private file and its passphrase to yourself.
cat ~/.ssh/campus_do.pubCheck: The uploaded key is the public key from the pair you will use to connect.
Choose the server and its cost
Where: DigitalOcean / Create → Droplets
Select Ubuntu 24.04 LTS, your region, a plan and the key you just added. Review the displayed price and every add-on before clicking Create. Give it a name you will recognize. Keep this learning server separate from production.
Check: The Droplet is running, and you know its public IPv4 address, selected key and expected recurring cost.
Restrict incoming connections
Where: DigitalOcean / Networking → Firewalls
Create a Cloud Firewall and inspect its rules before attaching it to this Droplet. Allow inbound TCP 22 only from your public IPv4 address, using /32 for one address. Remove broad inbound sources and other inbound rules for this learning path. Leave the default outbound allowance so updates, DNS and HTTPS can work.
Check: The attached firewall allows SSH from your address, not from all IPv4 or IPv6 addresses. It is attached only to the intended learning Droplet.
Make the first SSH connection
Where: Your computer / a new terminal
Replace YOUR_DROPLET_IP with the address shown in DigitalOcean. Verify the first-connection host fingerprint through the Droplet console before accepting it. Keep this root session open while setting up and testing your regular account.
ssh -i ~/.ssh/campus_do root@YOUR_DROPLET_IPCheck: The remote prompt belongs to your new Droplet. A fingerprint mismatch is a reason to stop, not erase known-host records.
Create your everyday account
Where: The root SSH session / fresh learning Droplet only
Create campus with sudo access and install the authorized public keys for that account. Enter the new account password privately in your terminal. This block stops if campus already exists; inspect existing accounts rather than changing them blindly. It copies root’s authorized public keys, so use it only when those are exactly the keys you intend for campus.
if id campus >/dev/null 2>&1; then printf '%s\n' 'campus already exists. Stop and inspect it.' else adduser campus && usermod -aG sudo campus && install -d -m 700 -o campus -g campus /home/campus/.ssh && install -m 600 -o campus -g campus /root/.ssh/authorized_keys /home/campus/.ssh/authorized_keys fiCheck: The new account exists; its .ssh directory belongs to campus and its authorized_keys contains only the intended public keys.
Test the account before moving on
Where: Your computer / a second terminal
Open a separate connection as campus. In that remote session, run whoami and sudo -v; use the account password you set if prompted. Only after this works should you close the original root session. Use campus for the Hermes guide.
ssh -i ~/.ssh/campus_do campus@YOUR_DROPLET_IPCheck: The second session identifies you as campus, and sudo -v succeeds. You still know how to reach the server’s console.
Troubleshooting
- SSH times out
- Check the Droplet IP and current source IP in the firewall. Use DigitalOcean’s console if your address changed.
- Permission denied (publickey)
- Check the username, the -i filename, and that the matching public key was selected when the Droplet was created.
- You no longer need the server
- Back up what you need first. The owner can then destroy the Droplet in DigitalOcean; this is destructive. Separately review billable backups, snapshots or volumes. Powering off alone does not end Droplet charges.
Completion checklist
- A running Droplet at a cost you chose.
- A working SSH connection as campus, with sudo checked.
- A firewall limited to your intended SSH source. This is a learning baseline, not a full production security audit.
Official references
- Droplet quickstart
- SSH keys
- SSH connection
- Cloud Firewall rules
- Droplet pricing
- Ubuntu user management
- Ubuntu OpenSSH