克隆后无法通过SSH访问Google Cloud实例 [英] Google Cloud instance can't be accessed via SSH after cloning

查看:126
本文介绍了克隆后无法通过SSH访问Google Cloud实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想在这里寻求帮助.我有一个托管许多网站的计算引擎实例.这些是我采取的步骤:

I'm desperate for help here. I have a compute engine instance that hosts a lot of websites. These are the steps that I took:

  1. 转到Compute Engine>快照并为我的实例拍摄快照

  1. Go to Compute Engine > Snapshots and take a snapshot of my instance

单击新创建的快照,然后单击创建实例".

Click on the newly created snapshot and click Create Instance.

新实例具有当前运行实例的所有配置

The new instance has all the configs of the current running instance

然后,当我尝试通过SSH访问新实例时,它将无法工作.错误消息:

Then when I tried to access the new instance via SSH, it wouldn't work. Error message:

连接失败 我们无法在端口22上连接到VM.了解有关此问题的可能原因的更多信息."

"Connection Failed We are unable to connect to the VM on port 22. Learn more about possible causes of this issue."

点击了解更多信息可以使我进入 https://cloud. google.com/compute/docs/ssh-in-browser#ssherror

Clicking on Learn more gets me to https://cloud.google.com/compute/docs/ssh-in-browser#ssherror

实例正在启动并且sshd尚未运行-不知道如何检查

实例未运行sshd -不知道如何检查

sshd正在监听的端口不是您要连接的端口-我的当前实例的ssh正在端口22上运行,所以我想这很好吗?

sshd is listening on a port other than the one you are connecting to - My current instance is having ssh running on port 22 so I guess this is fine?

没有防火墙规则允许端口上的SSH访问-同样,我当前的实例正在运行ssh,所以我不认为这是由于防火墙造成的吧?

There is no firewall rule allowing SSH access on the port - Again, my current instance is having ssh running so I don't think it's because of firewall, right?

启用了允许SSH访问的防火墙规则,但未将其配置为允许来自GCP控制台服务的连接.-与上述相同

实例已关闭-实例仍在运行.

奇怪的是,如果我从头开始创建一个新实例,然后执行上述步骤以克隆到一个新实例,那么可以通过SSH正常访问该新实例.

Strange thing is if I create a fresh instance from scratch and then do the steps above to clone to a new instance then that new instance can be accessed normally via SSH.

有人可以告诉我如何解决此问题吗?或向我展示如何查看日志,检查出了什么问题等,而我尝试通过google进行搜索时却与所有行话或在何处找到特定的东西很困惑.很抱歉,无法显示文字.谢谢

Can anyone show me how to fix this if possible? Or show me how to see logs, check for what went wrong etc as I tried to google but pretty confused with all the jargons or where to find a particular stuff. Sorry for the wall of text. Thanks

**

**:我得到了Google的技术支持.以下步骤可能会对其他人有所帮助,但是对我却没有帮助,因为当我到达步骤7时,我一直等待着,无法进入登录页面.

**: I got technical support from Google. The steps below might help someone else, but not me as when I reached step 7, I waited forever and couldn't get to the login page.

1.)转到"VM实例"页面,然后单击您的VM的实例名称.

1.) Go to the VM instances page and click on the Instance name of your VM.

2.)单击页面顶部的编辑"按钮.

2.) Click the Edit button at the top of the page.

3.)在自定义元数据"下,单击添加项目".

3.) Under Custom metadata, click Add item.

4.)将密钥"设置为启动脚本",并将值"设置为此脚本:

4.) Set 'Key' to 'startup-script' and set 'Value' to this script:

#! /bin/bash 

useradd -G sudo USERNAME 

echo 'USERNAME:PASSWORD' | chpasswd

注意:将USERNAME和PASSWORD的值更改为您选择的名称和密码.

NOTE: change the value of USERNAME and PASSWORD to the name and password of your choice.

5.)选中SSH按钮下方的框,启用启用连接到串行端口".

5.) Enable "Enable connecting to serial ports" by checking the box below the SSH button.

6.)单击保存",然后单击页面顶部的重置".等待一段时间以重新启动实例.

6.) Click Save and then click RESET on the top of the page. Wait for some time for the instance to reboot.

7.)单击页面中的连接到串行端口".在新窗口中,您可能需要稍等片刻,然后按一次Enter键;然后,您应该会看到登录提示.

7.) Click on 'Connect to serial port' in the page. In the new window, you might need to wait a bit and press on Enter of your keyboard once; then, you should see the login prompt.

8.)使用您提供的用户名和密码登录.

8.) Login using the USERNAME and PASSWORD you provided.

注意:为了确保数据安全,请不要共享您的任何密码和用户名.

Note: Please do not share any of your password and username for your data security.

由于上述步骤无法帮助我,并且Google支持代表查看了日志,但没有发现任何错误,因此她建议按照本指南

As those steps above couldn't help me and the Google support representative looked at the log but didn't see anything wrong, she suggested to debug SSH following this guide https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh#use_your_disk_on_a_new_instance which I will do when I have time. Feel like I'm writing an essay. Will keep posted

推荐答案

可以执行的故障排除步骤如下:

The troubleshooting steps that you can follow are:

  1. 使用串行控制台来查看您的实例日志,并检查您从快照创建的新实例是否无法启动到启动ssh守护程序的适当运行级别.如果未启动sshd,则您将没有ssh访问实例的权限.
  2. 如果实例不影响生产,则可以尝试重新启动它,然后尝试再次获得ssh访问.可能是因为某些问题导致实例无法正常启动,然后重新启动它可以解决该问题.

  1. Use the serial console to view your instance logs and check whether the new instance you created from the snapshot failed to start to the appropriate run level where the ssh daemon would get started. If sshd was not started you would not have ssh access to your instance.
  2. You can try restarting the instance if it doesn’t affect production and try to gain ssh access again. Might be that some issue prevented the instance from starting up properly and restarting it could fix it.

如果先前的实例创建不正确,您可以尝试从快照中创建另一个VM实例.

You can try creating another VM instance from the snapshot in case the previous instance wasn’t created properly.

这篇关于克隆后无法通过SSH访问Google Cloud实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆