/ core-os

How Do I Add an SSH Key to a DigitalOcean CoreOS Droplet?

CoreOS runs the Docker container for useful-things.info. I'd like to say this container runs 100% of the time, but alas, it does not. When it doesn't, the site is not available. To fix the problem, I need to login to the CoreOS instance on digitalocean.com, which is only possible using SSH from a pre-authorized client computer. Since I don't have my home computer with me 24/7, this presents a problem.

When I originally setup the site, I only had my home computer authorized. Given that CoreOS only accepts SSH keys when CoreOS itself is installed for the first time, it's not possible to add SSH keys after installation. You must destroy the Droplet, create a new CoreOS Droplet, assign it to the domain again and restore the backup.

This sounds complicated and time-consuming, but Digital Ocean's website makes it easy. The procedure is as follows:

Backup The Site

I use Scooter Software's Beyond Compare to sync file across computers. The Pro version supports SFTP profiles. I create an SFTP profile to "core@useful-things.info", create a "Folder Sync" session, then use it to copy all of the files any folders to a local folder. This includes the ghost database which is a single file.

Destroy the Droplet

Select the Droplet. From the list of functions on the left, select "Destroy". You can destroy or rebuild the droplet. Pick "Destroy".

This will completely remove the site, but the domain entry to point useful-things.info at the IP address of the Droplet will not be changed.

Create a New Droplet

Create a new Droplet using the CoreOS Stable image. Select a plan an the other options. This is where you add SSH keys. Presumably you've added the SSH Key for all of the computers you wish to use to your account already... if so, they will show up in the list (otherwise use the option to add SSH Keys first). Select all the SSH Keys to add. Then create the Droplet.

The system will show progress.

Reassign the Domain

Select the Droplet, then select networking. In the networking screen an entry with the old IP address will be shown. Update the entry to point to the new IP address. Given that the DNS server is on digitalocean.com, it will update immediately.

Re-build/Restore the site.

Using Beyond Compare, the profile "core@useful-things.info" will point to the new droplet. Just refresh and sync to the fresh filesystem.

Login and Start the Container

Using "ssh core@useful-things.info", run the docker command to start the container. I have a "runghost" command that does this.

Test Access

Use a browser to access http://useful-things.info and verify that it works.

Test SSH Access

Login using SSH from of the authorized equipment.

How Do I Add an SSH Key to a DigitalOcean CoreOS Droplet?
Share this