代码之家  ›  专栏  ›  技术社区  ›  Ark-kun

GCE-VM无法SSH到它刚刚在另一个项目中创建的新GCE-VM

  •  0
  • Ark-kun  · 技术社区  · 8 年前

    我正在尝试从project-a中的GCE VM运行以下PoC脚本。

    gcloud config set project project-b
    gcloud compute instances create gce-vm-b --zone=us-west1-a
    gcloud compute ssh --zone=us-west1-a gce-vm-b -- hostname
    

    已成功创建VM:

    NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS 
    gce-vm-b us-west1-a n1-standard-16 10.12.34.56 12.34.56.78 RUNNING 
    

    但尝试SSH时出现以下错误:

    WARNING: The public SSH key file for gcloud does not exist. 
    WARNING: The private SSH key file for gcloud does not exist. 
    WARNING: You do not have an SSH key for gcloud. 
    WARNING: SSH keygen will be executed to generate a key. 
    Generating public/private rsa key pair. 
    Your identification has been saved in /root/.ssh/google_compute_engine. 
    Your public key has been saved in /root/.ssh/google_compute_engine.pub. 
    The key fingerprint is: 
    ...
    Updating project ssh metadata... 
    .....................Updated [https://www.googleapis.com/compute/v1/projects/project-b]. 
    >.done. 
    >Waiting for SSH key to propagate. 
    >ssh: connect to host 12.34.56.78 port 22: Connection timed out 
    >ERROR: (gcloud.compute.ssh) Could not SSH into the instance. It is possible that your SSH key has not propagated to the instance yet. Try running this command again. If you still cannot connect, verify that the firewall and instance are set to accept ssh traffic. 
    

    跑步 gcloud compute config-ssh ssh: connect to host 12.34.56.78 port 22: Connection timed out

    我已尝试向项目中添加防火墙规则:

    gcloud compute firewall-rules create default-allow-ssh --allow tcp:22 
    

    Creating firewall... 
    ...........Created [https://www.googleapis.com/compute/v1/projects/project-b/global/firewalls/default-allow-ssh]. 
    done. 
    NAME NETWORK DIRECTION PRIORITY ALLOW DENY 
    default-allow-ssh default INGRESS 1000 tcp:22
    

    错误现在是 Permission denied (publickey)

    gcloud compute ssh --zone=us-west1-a gce-vm-b -- hostname 
    

    .

    Pseudo-terminal will not be allocated because stdin is not a terminal. 
    Warning: Permanently added 'compute.4123124124324242' (ECDSA) to the list of known hosts. 
    Permission denied (publickey). 
    ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
    

    另外,项目-a“VM”是由Prow cluster运行的容器(由G运行) K公司

    1 回复  |  直到 8 年前
        1
  •  1
  •   Héctor Neri    8 年前

    “Permission denied(publickey)”表示无法验证用户名的公钥。

    您尚未在命令中指定用户,因此选择了环境中的用户,可能不允许该用户进入实例gce-vm-b。请根据 public SSH key metadata .