-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
r/linux_virtual_machine: support for parsing ssh2 keys #10167
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@AleFazio hello, please did you find a solution yet, i am having the same problem as well |
This comment was marked as off-topic.
This comment was marked as off-topic.
I have the same issue in v2.99 azure provider It seems to be fine if the file format is as per Linux ssh-keygen, i.e. a single line like this: |
Hi, Are there any workarounds for this issue to avoid terraform forcing replacement when importing existing virtual machines which has public key in this format |
Indeed, it’s unbelievable Microsoft hasn’t fixed this yet |
Community Note
Description
Good morning,
We have an infrastructure generated in Azure which we are trying to terraform.
In particular, we have a problem with admin_ssh_key "public_key" in "azurerm_linux_virtual_machine" when the key imported is in the following format:
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20200715"
ssh-rsa AAA....
---- END SSH2 PUBLIC KEY --
We have several virtual machines with their linked ssh key in different format and we reference to them using the file function:
admin_ssh_key {
username = "azureuser"
public_key = file(<path_to_ssh_key>)
}
After performing the command terraform plan, it manages to compare information with keys in string format but not in the ---- BEGIN SSH2 PUBLIC KEY ---- format.
I tried using file either with or without .pub extension but I didn't get any result.
Below a screenshot of the error:
I also tried using an input key even in the ssh-rsa common format (ignoring the 'BEGIN/END' and 'comment' keyword) but Terraform tries to forces replacement in this case.
Terraform (and AzureRM Provider) Version
Versions:
Terraform v0.13.2
Provider azurerm: 2.82.0
Affected Resource(s)
azurerm_linux_virtual_machine
Expected Behaviour
The input key should be correctly decoded and matched with the one imported along with the vm configuration in the state file
Actual Behaviour
Decoding error (Error: Error decoding "admin_ssh_key.0.public_key" for public key data) when running terraform plan/apply
Steps to Reproduce
'---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20200715"
ssh-rsa AAA....
---- END SSH2 PUBLIC KEY --'
References
In #9238 I mentioned this issue along with the 'forces replacement' issue (when the key is created through the portal) since I thought they could be related to the same problem but unfortunately they're not.
The text was updated successfully, but these errors were encountered: