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

import_key variable does not insert public ssh key into ~/.ssh/authorized_keys #45

Closed
scarolan opened this issue Nov 6, 2019 · 3 comments

Comments

@scarolan
Copy link

scarolan commented Nov 6, 2019

I configured the module below using a variable to define the import_key input:

module "terraform-enterprise" {
  source  = "hashicorp/terraform-enterprise/azurerm"
  version = "0.1.0"
  # insert the 8 required variables here
  domain                        = "${var.domain}"
  key_vault_name                = "${var.key_vault_name}"
  license_file                  = "${var.license_file}"
  tls_pfx_certificate           = "${var.tls_pfx_certificate}"
  tls_pfx_certificate_password  = "${var.tls_pfx_certificate_password}"
  key_vault_resource_group_name = "${var.key_vault_resource_group_name}"
  domain_resource_group_name    = "${var.domain_resource_group_name}"
  resource_group_name           = "${data.terraform_remote_state.azure-tfe-infra.tfe_rg}"
  virtual_network_name          = "${data.terraform_remote_state.azure-tfe-infra.tfe_vnet}"
  subnet                        = "${data.terraform_remote_state.azure-tfe-infra.tfe_subnet}"
  import_key                    = "${var.import_key}"
}

But the VMs never get the content of the import_key variable inserted into ~/.ssh/authorized_keys

@erindatkinson
Copy link
Contributor

So that variable looks like it might only work on Ubuntu (which is a thing we'll need to call out) but also follows the schema defined here:

https://cloudinit.readthedocs.io/en/latest/topics/modules.html#ssh-import-id

Are you passing the public ssh key in directly?

@evanphx
Copy link
Contributor

evanphx commented Nov 7, 2019

Yes, this needs to be documented more about the format that the value should take, namely conforming to the docs @erindatkinson listed above.

@ausfestivus
Copy link
Contributor

ausfestivus commented Dec 9, 2019

Can I second what @scarolan has stated above?
I have supplied my own public key via the import_key var and the public key is not being inserted into the ~ubuntu/.ssh/authorized_keys file.

I took at a look in the cloud-init-output.log for some ssh content and this is what it came back with:

root@tfe-vpkqok5r-primary-0:/var/log# cat cloud-init-output.log | grep -i ssh
Your identification has been saved in /etc/ssh/ssh_host_rsa_key.
Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub.
Your identification has been saved in /etc/ssh/ssh_host_dsa_key.
Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub.
Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key.
Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub.
Your identification has been saved in /etc/ssh/ssh_host_ed25519_key.
Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub.
/tmp/ssh-auth-key-check36ddrtk3.pub is not a public key file.
/tmp/ssh-auth-key-checkxpspvjwr.pub is not a public key file.
/tmp/ssh-auth-key-checkk85nj4m6.pub is not a public key file.
/tmp/ssh-auth-key-checkq5onvx6y.pub is not a public key file.
2019-12-09 02:45:19,010 INFO [0] SSH keys [Authorized]
2019-12-09 02:45:19,011 ERROR No matching keys found for [ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAA/gCfGswRr/BzYSsjEv1kCZ4Pdhc/a/OL2zAf3q+ORYnt2CLVxD/61ptbVRFTnHN2+DBdvWifwivRdIivKWUmQuX7vAQx7oEAs6rgAHlBmjhTy6q8sOZHnW2qz7vXyXKsApR5QfNHU/1RC2GnPTEUn2atD1tz6dA9TzCLhEMWiifxfniaXgSEExtyD8pWhQ6CRz6vtQkBGPY5hCwUChJkfzantTbViCLn8ieGAFYRQ8Ch4XbtixKoP8EhjC73mOSYmgJfHUd9vWf/npDtMkaBHIfCX6rnQU4Chy1Vcyy3HW2B3Ivr9G8jym46BsjdBtd0MxOMsCsP4SvkOqHQlVkz [email protected]]
2019-12-09 02:45:19,012 - util.py[WARNING]: Failed to run command to import ubuntu ssh ids
2019-12-09 02:45:19,039 - util.py[WARNING]: ssh-import-id failed for: ubuntu ['ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAA/gCfGswRr/BzYSsjEv1kCZ4Pdhc/a/OL2zAf3q+ORYnt2CLVxD/61ptbVRFTnHN2+DBdvWifwivRdIivKWUmQuX7vAQx7oEAs6rgAHlBmjhTy6q8sOZHnW2qz7vXyXKsApR5QfNHU/1RC2GnPTEUn2atD1tz6dA9TzCLhEMWiifxfniaXgSEExtyD8pWhQ6CRz6vtQkBGPY5hCwUChJkfzantTbViCLn8ieGAFYRQ8Ch4XbtixKoP8EhjC73mOSYmgJfHUd9vWf/npDtMkaBHIfCX6rnQU4Chy1Vcyy3HW2B3Ivr9G8jym46BsjdBtd0MxOMsCsP4SvkOqHQlVkz [email protected]']
2019-12-09 02:45:19,040 - util.py[WARNING]: Running module ssh-import-id (<module 'cloudinit.config.cc_ssh_import_id' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_import_id.py'>) failed

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

4 participants