DigitalOcean CLI Cheat Sheet
2023-04-15 (updated 2025-10-25)Notes | 1 min read
#bash #digitalocean #doctl #infrastructure #productivity
Add SSH key from local machine
keyFile=<Location of public key, ie. ~/.ssh/id_rsa.pub>
doctl compute ssh-key create "<NAME OF KEY>" --public-key "$(< $keyFile)"
Sane Webapp Firewall
Creates a firewall that has some workable/“sane” default rules for a webapp and assigns it to all droplets
that have the tag default-webapp-fw.
Details
Inbound:

Outbound:

doctl compute firewall create --name "default-webapp" --tag-names="default-webapp-fw" \
--inbound-rules="protocol:icmp,address:0.0.0.0/0,address:::/0 protocol:tcp,ports:22,address:0.0.0.0/0,address:::/0 protocol:tcp,ports:80,address:0.0.0.0/0,address:::/0 protocol:tcp,ports:443,address:0.0.0.0/0,address:::/0" \
--outbound-rules="protocol:icmp,address:0.0.0.0/0,address:::/0 protocol:tcp,ports:0,address:0.0.0.0/0,address:::/0 protocol:udp,ports:0,address:0.0.0.0/0,address:::/0"