Skip to content

Instantly share code, notes, and snippets.

@popey
Created January 7, 2019 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save popey/924311f621d7f6d6329670a9df02b740 to your computer and use it in GitHub Desktop.
Save popey/924311f621d7f6d6329670a9df02b740 to your computer and use it in GitHub Desktop.
Setup Digitial Ocean droplets for class

Sign up for digital ocean

Install doctl on your machine (useful for managing droplets)

snap install doctl

Setup doctl

Get API key

https://cloud.digitalocean.com/account/api/tokens

Auth doctl

doctl auth init

Test doctl

doctl compute droplet list

Add your SSH key to your account

https://cloud.digitalocean.com/account/security

  • Create a droplet
  • Ubuntu 16.04
  • 2GB / 1 CPU
  • London region
  • Add your ssh
  • hostname snapcraftiobase
  • Note IP of host

Setup base image

SSH as root to the machine

ssh root@IP

Create a user

root@snapcraftiobase:~# adduser snapcraft
Adding user `snapcraft' ...
Adding new group `snapcraft' (1000) ...
Adding new user `snapcraft' (1000) with group `snapcraft' ...
Creating home directory `/home/snapcraft' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for snapcraft
Enter the new value, or press ENTER for the default
        Full Name []: 
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] y

Note the password you use

Give the user sudo access

usermod -aG sudo snapcraft

Install software

Delegates use ssh to connect to the server apt install openssh-server

snap install snapcraft --classic

Optionally install multipass, if you don't, snapcraft will prompt to install it on first time you run snap install multipass --classic --beta

Allow ssh

nano /etc/ssh/sshd_config

Set the following: PasswordAuthentication yes

systemctl restart ssh

Snapshot machine

Back in the digital ocean web UI, take a snapshot of the VM

Spin up multiple VMs based on the snapshot

List them doctl compute image list Grab the ID number from the output (first column)

Get ssh-key fingerprint

doctl compute ssh-key list Grab FingerPrint from third column

Spin up one machine

Plug in IMAGE and SSHKEY from above doctl compute droplet create ubuntuserver01 --size 2gb --image $IMAGE --region lon1 --ssh-keys $SSHKEY

Spin up multiple..

for f in {01..10}; 
do
  doctl compute droplet create ubuntuserver"$f" --size 2gb --image $IMAGE --region lon1 --ssh-keys $SSHKEY
done

List to get IP addresses

doctl compute droplet list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment