created Public key and private key but unable to login VM by using Putty, how to overcome this issue? and I'm copy those keys and saved as .ppk but those keys not working login by using putty??
# Create (and display) an SSH key
resource "tls_private_key" "example_ssh" {
algorithm = "RSA"`
rsa_bits = 4096
}
output "tls_private_key" {
value = tls_private_key.example_ssh.private_key_pem
sensitive = true
}
admin_ssh_key {
username = "azureuser"
public_key = tls_private_key.example_ssh.public_key_openssh
}
Thanks in advance
Worked for me like this:
resource "tls_private_key" "example_ssh" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "local_file" "private_key" {
content = tls_private_key.example_ssh.private_key_pem
filename = "example.pem"
file_permission = "0600"
}
admin_ssh_key {
username = "azureuser"
public_key = tls_private_key.example_ssh.public_key_openssh
}
And then ssh -i example.pem azureuser@PUBLIC_IP
.
NOTE: Please do not forget to allow SSH Port 22 via Inbound Rule (NSG) on the NIC or the Subnet.