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

Azure ssh key issue #2419

Closed
tayzlor opened this issue Jun 22, 2015 · 6 comments
Closed

Azure ssh key issue #2419

tayzlor opened this issue Jun 22, 2015 · 6 comments

Comments

@tayzlor
Copy link

tayzlor commented Jun 22, 2015

Hi there,
I'm trying out the azure provider in the latest master branch and receiving the following issue when trying to provision an instance -

* Error creating instance NAME: Error response from Azure. Code: BadRequest, Message: The certificate with thumbprint THUMBPRINT_HERE was not found.

My azure_instance looks something like this -

resource "azure_instance" "master" {
  name          = "instance-${count.index}"
  count          = "${var.masters}"
  image                       = "custom-image-name"
  size                          = "${var.instance_type.master}"
  security_group    = "${azure_security_group.default.name}"
  location               = "${var.region}"
  username           = "${var.username}"
  ssh_key_thumbprint = "${var.ssh_key_thumbprint}"

  endpoint {
    name         = "SSH"
    protocol     = "tcp"
    public_port  = 22
    private_port = 22
  }
}

I'm using a Linux host and building with a custom Ubuntu based image i've baked using the Packer azure plugin.

I've followed this guide to create an SSH key for Azure - https://azure.microsoft.com/en-gb/documentation/articles/virtual-machines-linux-use-ssh-key/

and uploaded it to https://manage.windowsazure.com/@myusername#Workspaces/AdminTasks/ListManagementCertificates

I'm wondering if this is just a user error (i've missed a step) or if there is something wrong here.
Following the docs for azure i'm using the AZURE_SETTINGS_FILE downloaded from https://manage.windowsazure.com/publishsettings

How do I associate an SSH key with my instance, is this possible via terraform in a similar way to http://terraform.io/docs/providers/aws/r/key_pair.html ?

@tayzlor
Copy link
Author

tayzlor commented Jun 22, 2015

As an aside if I use a password instead of an ssh_key_thumbprint the instances provision fine.

@stonevil
Copy link

This same issue

@stonevil
Copy link

Look like this is issue with azure-sdk-for-go. This same issue with small Go app created with azure-sdk-for-go.

@keymon
Copy link
Contributor

keymon commented Aug 28, 2015

In #3099 we request a feature to be able to upload the ssh key from terraform.

In this commit you can see that we implemented automation around this using a local_exec provisioner in the azure_hosted_service which calls the azure-cli. You might find this useful.

@xied75
Copy link

xied75 commented Nov 27, 2015

Guys, all wrong direction. For those of you who made the correct decision to stick with TF for Azure, here is what I found after a whole day wasted on this:

0, we are talking about classic ASM mode here.
1, the "Management Certificates" you can see and upload in the classic portal, as the name suggests, are for Management purpose only, things like authenticate you via Visual Studio or azure-cli to reach the api endpoint.
2, what you need for ssh login to your deployed Linux VM, is Certificates that belong to a Cloud Service, i.e. the Cloud Service you are deploying your VM into.
3, during deploy, Azure simply get your public key from the cert and put it under /home/you/.ssh/authorized_keys

It's very strange to understand consider AWS/CloudStack would let you create ssh public key as an object and reference that in your deployment. But anyway, this is Microsoft we are talking about.

So the proper procedure:
1, you create id_rsa, id_rsa.pub as normal.
2, you generate a .cer file.
3, you upload the .cer file into your Cloud Service.
4, reference its thumbprint in your tf.
5, login via -i id_rsa

If you are making your own image, leave the id_rsa.pub in authorized_keys as normal. Otherwise for Azure images, I believe they all have some kind of cloud init in it to fetch keys at boot time.

Things TF doesn't do: upload .cer step. Will look further as otherwise this is not full automation.

@ghost
Copy link

ghost commented Apr 11, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants