Concerning Vagrant with Digital Ocean as a Provider and multiple users...

November 5, 2014 2.1k views

I'm a bit confused about one aspect of using Digital Ocean as a provider for Vagrant. How is it possible that multiple developers can access the same Vagrant Box if it is on Digital Ocean? Would they all need the same ssh key and API tokens?

Thank you.

1 Answer

When specifying the DigitalOcean user account that will create the droplet, you can only set one user and API token. Though you can still take advantage of all the different powerful provisioners that Vagrant can employ to configure the droplet. You can create new user accounts, add ssh keys, etc...

Here's an extremely simple example that runs the command ssh-import-id on the newly created droplet to import the public ssh keys associated with the GitHub user andrewsomething It's one quick way to get another developer's key on the machine:

Vagrant.configure('2') do |config|

  config.vm.provider :digital_ocean do |provider, override|
    override.ssh.private_key_path = '~/.ssh/id_rsa' = 'digital_ocean'
    override.vm.box_url = ""

    provider.token = 'MY_API_TOKEN'
    provider.image = '14.04 x64'
    provider.region = 'nyc3'
    provider.size = '512mb'
    provider.ssh_key_name = 'ssh_key_name'

  config.vm.provision "shell",
    inline: "ssh-import-id gh:andrewsomething"


This uses the "shell" provisioner, but you can also use more sophisticated configuration management tools like Puppet, Chef, and Ansible.

Have another answer? Share your knowledge.