Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[documentation] Clarify the role of override.ssh.private_key_path vs provider.ssh_key_name #223

Closed
CristianCantoro opened this issue Jan 4, 2016 · 1 comment

Comments

@CristianCantoro
Copy link

Hi,

I am using this plugin, to provision a machine on DO.

My public ssh key was already part of my DO account.

if I do not set the provider.ssh_key_name in the Vagrantfile I get the following error:

$ vagrant up --provider=digital_ocean
Bringing machine 'default' up with 'digital_ocean' provider...
==> default: Creating new SSH key: Vagrant...
There was an issue with the request made to the DigitalOcean
API at:

Path: /v2/account/keys
URI Params: {:name=>"Vagrant", :public_key=>"[snip]"}

The response status from the API was:

Status: 422
Response: {"id"=>"unprocessable_entity", "message"=>"SSH Key is already in use on your account"}

If I set the provider.ssh_key_name to the key names then everything works. The key name can be obtained using the command tugboatkeys.

Please note that I have chosen as provider.ssh_key_namethe name of the same key that I have indicated in override.ssh.private_key_path (i.e. '~/.ssh/id_rsa' is the private key corresponding to the $DIGITALOCEAN_SSH_KEY_NAME public key in my DO accout).

Here is the example Vagrantfile with some slight modification to fix this problem, I am using environment variables to store my private data:

Vagrant.configure('2') do |config|
  config.vm.hostname = 'dropletname.example.com'
  # Alternatively, use provider.name below to set the Droplet name. config.vm.hostname takes precedence.
  config.vm.provider :digital_ocean do |provider, override|

    # This is akways needed but if the key is already used in the DO account
    # you *need* to set the provider.ssh_key_name parameter.
    override.ssh.private_key_path = '~/.ssh/id_rsa'

    override.vm.box = 'digital_ocean'
    override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"

    provider.token = ENV['DIGITALOCEAN_TOKEN']
    provider.ssh_key_name = ENV['DIGITALOCEAN_SSH_KEY_NAME']
    provider.image = 'ubuntu-14-04-x64'
    provider.region = 'nyc2'
    provider.size = '512mb'
  end
end

I think that the documentation is unclear as of now, and this error could cause confusion.
Thank you for this great plugin.

@CristianCantoro CristianCantoro changed the title [documentation] Clarify the role of override.ssh.private_key_path and provider.ssh_key_name [documentation] Clarify the role of override.ssh.private_key_path vs provider.ssh_key_name Jan 4, 2016
@seth-reeser
Copy link
Member

Thank you for your feedback - by default everything works as expected. We feel this would cause more confusion as we currently note that by default, the key name is Vagrant.

provider.ssh_key_name
A string representing the name to use when creating a DigitalOcean SSH key for droplet authentication. It defaults to Vagrant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants