The sample has an error with respect to Keys so the VM won't deploy.
Error: Error applying plan:
1 error(s) occurred:
azurerm_virtual_machine.myterraformvm: 1 error(s) occurred:
azurerm_virtual_machine.myterraformvm: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid." Target="linuxConfiguration.ssh.publicKeys.keyData"
To work around this I removed the portion of the VM resource referencing the SSH keys and changed the disabled password authentication to false. Then need to add the password property.
}
os_profile {
computer_name = "hostname"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@deltadan Thanks for your feedback! We will investigate and update as appropriate.
@deltadan Thanks for the feedback! I have assigned the issue to the content author to investigate further and update the document as appropriate.
@deltadan: I got the same error because we need to update the field in the template: key_data = "ssh-rsa AAAAB3Nz{snip}hwhqT9h" with appropriate public ssh_id as this is a dummy placeholder and container{snip}.
Please check if you have missed the same step.
Alternatively we can provide this line to retrieve the pre-generated public key from the local machine in the .tf file
key_data = "${file("/home/{localmachine-username}/.ssh/id_rsa.pub")}"
e.g. "${file("/home/terraform/.ssh/id_rsa.pub")}"
There's also an example from azure github repo for generating the public key in the .tf file and using the same in the main.tf file
https://github.com/terraform-providers/terraform-provider-azurerm/tree/master/examples/virtual-machines/bastion-box
Hi @deltadan - were the comments by @codevulture and @kumarallamraju helpful? I just re-checked all the scripts and they are still working as expected (after I provide a valid SSH public key).
For Linux VMs, SSH is the preferred method for auth (over password), let us know if for some reason it's still not working for you.
Thanks @echuvyrov
@deltadan I will close this out as there is no issue with the doc. If you are still having issues feel free to email me at [email protected] and provide me with your SubscriptionID and link to this issue and I can assist further.
I've tried both methods key_data = "ssh-rsa AAAAB3Nz{snip}hwhqT9h" with appropriate public ssh_id and key_data = "${local.public_ssh_key}" from that github repo bastion-box and failed to work.
Any ideas?
@qafro1 - what are the errors you're seeing?
error msg: azurerm_virtual_machine.myterraformvm: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid." Target="linuxConfiguration.ssh.publicKeys.keyData"
Im getting same error as qafro is getting. Can anyone please assist. Thank you
New-AzureRmVM : The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid.
ErrorCode: InvalidParameter
ErrorMessage: The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid.
ErrorTarget: linuxConfiguration.ssh.publicKeys.keyData
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 2721c7e2-9784-4b61-8e80-0c3483dc8d3f
At line:1 char:1
Anyone got through this error?
Any resolution for this error?
@echuvyrov Need your help in terms of your inputs on this error customers are seeing. Thanks :)
Azure Cloud are not accepting ssh key. They are accepting SSH2 key.
ssh key is something like this
SSH2 is something like that:
To make the SSH2 key open cmd (on windows) run the below command.
Ssh-keygen
it will ask u password and file name.
Press enter your SSH is created.
navigate your terminal to the location where you save your SSH key. By default the location is C:\Users*USERSNAME*/.ssh/id_rsa
In order to create ur key SSH2. U need to make the existing SSH to SHH2.
ssh-keygen -e -f c:users\USER/.ssh/id_rsa > c:users\USER/.ssh/id_rsa_ssh2.pub
If you want to see your SSH2 key below is the command to see SSH2 key
type id_rsa
@Muhammad-Taimur FYI You have posted your private SSH key online. SSH2 key looks like this
@JoeSainsburys thanks for pointing out I have removed that. 😊
Thank you
No problem. Might want to rotate the key because you can view edit history in git
I had this issue when my
admin_username = foo
admin_ssh_key {
username = foo
Usernames were different. Which makes sense because it was trying to place the key in to a non existent user's home directory.
Most helpful comment
Im getting same error as qafro is getting. Can anyone please assist. Thank you
New-AzureRmVM : The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid.
ErrorCode: InvalidParameter
ErrorMessage: The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid.
ErrorTarget: linuxConfiguration.ssh.publicKeys.keyData
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 2721c7e2-9784-4b61-8e80-0c3483dc8d3f
At line:1 char:1
~~~