DigitalOcean CLI Cheat Sheet

Add SSH key from local machine

keyFile=<Location of public key, ie. ~/.ssh/>
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.

Screenshots of the created firewall


Inbound rules


Inbound rules

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

See also