[英]how to copy local file to azure vm through terraform?
我正在尝试使用 terraform 在 Azure 中创建一个 VM,并将文件从本地计算机复制到 azure 上的远程虚拟机。
os_profile {
computer_name = "pdemo"
admin_username = "ubuntu"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
key_data = "ssh-rsa ********************************** "
path = "/home/ubuntu/.ssh/authorized_keys"
}
}
provisioner "file" {
connection {
type = "ssh"
user = "ubuntu"
host = azurerm_public_ip.terraform-PUBLIC-IP.ip_address
private_key = file("/home/ubuntu/.ssh/id_rsa")
}
source = "/home/ubuntu/.ssh/terraform.pub"
destination = "/home/ubuntu/.ssh/terraform.pub"
}
}
它给出了一个错误:
azurerm_virtual_machine.terraform-app-VM: Still creating... [1m30s elapsed]
azurerm_virtual_machine.terraform-app-VM: Still creating... [1m40s elapsed]
azurerm_virtual_machine.terraform-app-VM: Still creating... [6m20s elapsed]
azurerm_virtual_machine.terraform-app-VM: Still creating... [6m30s elapsed]
Error: timeout - last error: SSH authentication failed (ubuntu@:22): ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
请检查您使用的私钥,因为错误显示身份验证问题。
还像这样添加agent=false
:
provisioner "file" {
connection {
type = "ssh"
user = "ubuntu"
host = azurerm_public_ip.terraform-PUBLIC-IP.ip_address
private_key = file("/home/ubuntu/.ssh/id_rsa")
agent = false
timeout = "10m"
}
source = "/home/ubuntu/.ssh/terraform.pub"
destination = "/home/ubuntu/.ssh/terraform.pub"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.