you might want to extract the host part in the url to make it work with GitHub Enterprise. It should be easy, although it might be out of scope. This is what'd do the trick:

1. Allow something like `github-url` in the cloud-init configuration, defaulting it to `https://api.github.com`.
2. Add `/api/v3` to that `github-url` when it's not the default one, and it doesn't include it yet.
3. Concat `github-url` to `/users/%s/keys` to generate the final url.

It's important that you allow to configure the whole url rather than only the host. GitHub Enterprise allows people to run github with `http`, and people do it.