gpt4 book ai didi

terraform ssh : handshake failed: ssh: unable to authenticate, 尝试的方法 [无公钥],不存在支持的方法

转载 作者:行者123 更新时间:2023-12-04 15:44:21 26 4
gpt4 key购买 nike

我不知道它试图通过 SSH 连接到哪里?进入新部署的资源?

如何更详细地诊断此错误?

Error: Error applying plan:

1 error occurred:
* module.deploy_nixos.null_resource.deploy_nixos: timeout - last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
data "google_compute_network" "default" {
name = "default"
}

resource "google_compute_firewall" "deploy-nixos" {
name = "deploy-nixos"
network = "${data.google_compute_network.default.name}"

allow {
protocol = "icmp"
}

// Allow SSH access
allow {
protocol = "tcp"
ports = ["22", "80", "443"]
}

source_tags = ["nixos"]
}

resource "google_compute_instance" "deploy-nixos" {
name = "deploy-nixos-example"
machine_type = "g1-small"
zone = "europe-west2-a"
# region = "eu-west2"

// Bind the firewall rules
tags = ["nixos"]

boot_disk {
initialize_params {
// Start with an image the deployer can SSH into
image = "${module.nixos_image_custom.self_link}"
size = "25"
}
}

network_interface {
network = "default"

// Give it a public IP
access_config {}
}

lifecycle {
// No need to re-deploy the machine if the image changed
// NixOS is already immutable
ignore_changes = ["boot_disk"]
}
}

module "deploy_nixos" {
source = "../../deploy_nixos"

// Deploy the given NixOS configuration. In this case it's the same as the
// original image. So if the configuration is changed later it will be
// deployed here.
nixos_config = "${path.module}/image_nixos_custom.nix"

target_user = "root"
target_host = "${google_compute_instance.deploy-nixos.network_interface.0.access_config.0.nat_ip}"

triggers = {
// Also re-deploy whenever the VM is re-created
instance_id = "${google_compute_instance.deploy-nixos.id}"
}
}

使用调试输出:
module.deploy_nixos.null_resource.deploy_nixos: Creating...
triggers.%: "" => "3"
triggers.deploy_nixos_drv: "" => "/nix/store/0dmz6dhqbk1g6ni3b92l95s377zbikaz-nixos-system-unnamed-19.03.172837.6c3826d1c93.drv"
triggers.deploy_nixos_keys: "" => "44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a"
triggers.instance_id: "" => "deploy-nixos-example"
module.deploy_nixos.null_resource.deploy_nixos: Provisioning with 'file'...
2019-06-08T22:31:00.030Z [DEBUG] plugin.terraform: file-provisioner (internal) 2019/06/08 22:31:00 [DEBUG] connecting to TCP connection for SSH
2019-06-08T22:31:00.041Z [DEBUG] plugin.terraform: file-provisioner (internal) 2019/06/08 22:31:00 [DEBUG] handshaking with SSH
2019-06-08T22:31:00.119Z [DEBUG] plugin.terraform: file-provisioner (internal) 2019/06/08 22:31:00 [WARN] ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2019-06-08T22:31:00.119Z [DEBUG] plugin.terraform: file-provisioner (internal) 2019/06

最佳答案

检查模块的来源 (source = "../../deploy_nixos") null_resource 可能在那里定义(这里的问题中没有显示)。您可能在那里使用了 terraform remote_exec 或文件配置器,您需要检查其中的连接属性。

示例 Terraform 连接属性如下所示

provisioner "file" {
source = "conf/myapp.conf"
destination = "/etc/myapp.conf"

connection {
type = "ssh"
user = "root"
password = "${var.root_password}"
}
}

更多详情请查看: https://www.terraform.io/docs/provisioners/connection.html

关于terraform ssh : handshake failed: ssh: unable to authenticate, 尝试的方法 [无公钥],不存在支持的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56510596/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com