简体   繁体   English

无法通过 ssh 连接到谷歌云实例

[英]Cannot ssh to google cloud instance

I'm newbie for GCP and I need your help which this is the step I had made.我是 GCP 的新手,我需要你的帮助,这是我所做的一步。 (1) I setup google cloud firewall rules to allow ssh on port 22 and I can ssh to my instance, CentOS7, correctly. (1) 我设置了谷歌云防火墙规则以允许端口 22 上的 ssh,我可以正确地 ssh 到我的实例 CentOS7。 (2) When I connect to my instance, I run some firewall script and after that I cannot ssh to my instance anymore. (2) 当我连接到我的实例时,我运行了一些防火墙脚本,之后我无法再通过 ssh 连接到我的实例。 It seem that script block ssh port even I enable it in the VPC Network > Firewall rules.即使我在 VPC 网络 > 防火墙规则中启用它,脚本似乎也会阻止 ssh 端口。 (3) Now I cannot connect to my instance including Open in browser window in the SSH menu on gcp console. (3) 现在我无法连接到我的实例,包括在 gcp 控制台的 SSH 菜单中打开浏览器窗口。

Is there any solution to connect my instance?有什么解决方案可以连接我的实例吗? Please help.请帮忙。

Thank in advance.预先感谢。 Bom

You probably change block ssh port by changing firewall configuration inside VM.您可能通过更改 VM 内的防火墙配置来更改阻止 ssh 端口。

So you can consider 2 options :所以你可以考虑 2 个选项:

1) Recreate VM if no sensitive data, or not too much work spent for the existing setup. 1) 如果没有敏感数据,或者没有为现有设置花费太多工作,则重新创建 VM。

2) Detach Boot disk and reuse it on another instance, to change the configuration files of firewal. 2) 分离启动盘并在另一个实例上重用,以更改firewal的配置文件。

check Official Docs - Use your disk on a new instance for that:检查官方文档 -为此在新实例上使用您的磁盘

gcloud compute instances delete $PROB_INSTANCE
    --keep-disks=boot

gcloud compute instances create new-instance
    --disk name=$BOOT_DISK,boot=yes,auto-delete=no

gcloud compute ssh new-instance

Hope it will help you.希望它会帮助你。

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

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