简体   繁体   English

从快照创建的 Google Cloud 虚拟机实例不允许 ssh

[英]Google Cloud virtual machine instance created from snapshot not allowing ssh

I have created a virtual machine instance from snapshot taken the production server.我从生产服务器拍摄的快照创建了一个虚拟机实例。 SSH key is set. SSH 密钥已设置。 But I am unable to ssh into instance both from the putty and google cloud ssh option from browser.但是我无法从浏览器的腻子和谷歌云 ssh 选项进入实例。

I have search around and find out that the issue new release which does not set the我四处搜索,发现问题新版本没有设置
default IP gateway for the instance.实例的默认 IP 网关。 I have set the IP gateway and restart the instance but instance still showing the same error .我已经设置了 IP 网关并重新启动了实例,但实例仍然显示相同的错误。 I have also check the Firewall rule and port 22 traffic allowed to the instance.我还检查了防火墙规则和允许实例的端口 22 流量。 All other instance in same zone are working on SSH other than instance newly created using snapshot.除了使用快照新创建的实例之外,同一区域中的所有其他实例都在 SSH 上工作。

After looking into the logs from the serial port ifup: failed to bring up lo从串口查看日志后ifup: failed to come up lo

Image of the error错误图像在此处输入图片说明

@Patrick answer helps me get to answer, explanatory steps @Patrick 回答帮助我回答,解释步骤

  1. 1) Serial Console. 1) 串行控制台。
    • Go to you instance detail and enable serial port.转到您的实例详细信息并启用串行端口。
    • Connect to your instance using serial port and login with the user and password使用串口连接到您的实例并使用用户名和密码登录
    • If you do not have user create one by following script as a startup-script如果您没有用户通过以下脚本作为启动脚本创建一个
      #!/bin/bash 
        sudo useradd -G sudo user
        sudo echo 'user:password' | chpasswd 
  • sudo systemctl status networking.service to check networking status sudo systemctl status networking.service 检查网络状态
  • Remove the /etc/network/interfaces.d/setup file then edit your /etc/network/interfaces删除 /etc/network/interfaces.d/setup 文件,然后编辑您的 /etc/network/interfaces
auto lo
iface lo inet loopback
  • Restart networking service by running sudo systemctl status networking.service通过运行 sudo systemctl statusnetworking.service 重新启动网络服务

2) Following startup script also work for me 2)以下启动脚本也适用于我

#!/bin/bash 
sudo dhclient eth0

It seems the issue here is that the network interface of your new instance is not coming up.这里的问题似乎是您的新实例的网络接口没有出现。 You can try one of two steps:您可以尝试以下两个步骤之一:

1) try connecting through the serial console . 1) 尝试通过串行控制台连接。 This does not connect through port 22 or use SSH.这不通过端口 22 连接或使用 SSH。 However, if the network card is not coming up at all, this may also fail.但是,如果网卡根本没有出现,这也可能会失败。

2) Add a startup script to the instance which will run the commands you need to configure the network card 2) 将启动脚本添加到实例中,该脚本将运行您需要配置网卡的命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM