Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 在GCP中挂起和恢复VM_Google Cloud Platform_Ssh - Fatal编程技术网

Google cloud platform 在GCP中挂起和恢复VM

Google cloud platform 在GCP中挂起和恢复VM,google-cloud-platform,ssh,Google Cloud Platform,Ssh,我在使用谷歌云平台时经常遇到问题。为了说明发生了什么,我创建了一个新的VM,通过gcloud beta compute ssh成功连接到它,并挂起了该实例 挂起后,我恢复了它,但无法再通过ssh连接到它,我运行了以下命令: gcloud beta compute ssh--zone“us-central1-a”“test vm”--project“my project”--ssh flag=“-vvv” 并收到以下输出: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, Open

我在使用谷歌云平台时经常遇到问题。为了说明发生了什么,我创建了一个新的VM,通过
gcloud beta compute ssh
成功连接到它,并挂起了该实例

挂起后,我恢复了它,但无法再通过ssh连接到它,我运行了以下命令:

gcloud beta compute ssh--zone“us-central1-a”“test vm”--project“my project”--ssh flag=“-vvv”

并收到以下输出:

OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/guilherme/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "34.66.57.82" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 34.66.57.82 [34.66.57.82] port 22.
debug1: connect to address 34.66.57.82 port 22: Connection timed out
ssh: connect to host 34.66.57.82 port 22: Connection timed out
ERROR: (gcloud.beta.compute.ssh) [/usr/bin/ssh] exited with return code [255].
挂起/恢复是在GCP平台上的浏览器中完成的


由于这个问题,我无法挂起任何VM,因为我每次都“丢失”它。有人知道如何正确地暂停它吗?谢谢

如果设置发生更改,“gcloud”拒绝ssh连接,则必须通过以下方式更新元数据中的ssh密钥:

sudo gcloud compute config-ssh
如果这导致您的配置文件中存储ssh密钥条目的条目不同,~/.ssh/config,请删除此文件并再次执行上述命令

如果系统的内部防火墙阻止端口22,您可以尝试以下步骤进行修复:

  • 在GCP控制台中,转到VM实例
  • 选择实例并单击“编辑”
  • 找到CustomMetadata选项并单击AddItem,键入StartupScript作为密钥,然后复制并通过sudoufwallowssh命令作为值。此命令将为SSH启用端口22

  • 为您的问题推荐此主题。

    添加启动脚本确实有效!谢谢你的回答!不客气,如果行得通,请接受我的答复。