[英]Unable to SSH into VM instance on Google Cloud Platform
[英]Cannot SSH Google Cloud VM instance after VM restart
我正在使用Google Cloud Platform并通过Google Cloud Console连接到我的VM实例。 重新启动VM而不保留静态IP因此在VM重新启动时,临时IP已更改。 我重新启动VM的原因是因为我注意到CPU利用率一直是100%,我认为这不是我本地VM实例(Ubuntu 16.x)的CPU,而是Google共享容器CPU利用率。 但它不允许我SSH到我的VM实例,所以我认为重启可能会有所帮助。
VM重启确实有所帮助,但IP改变了:(我运行Apache和Nginx服务器,所以我不得不手动更新相应配置文件中的新IP,以便我的应用程序运行。由于VM重启,我一直遇到连接到VM的问题实例通过SSH。
防火墙规则 - 确定(设置为允许端口22).ssh / sshd_conf - 确定(RSAauth是)GCE VM SSH密钥 - 确定(保存用户的公钥)
我尝试了以下步骤来解决问题,但徒劳无功
/etc/ssh/authorized_keys
为空时,我使用gcloud init
重新gcloud init
,它负责处理oAuth部分,但这并没有解决问题 gcloud command
,但它不断抛出错误server refused key
最后,这里是来自/var/log/syslog
Sep 25 22:30:01 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 CRON[1746]: (root) CMD (/google/scripts/gcloud_docker_auth.sh)
Sep 25 22:33:19 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: credentials-service INFO:root:Proxying devshell request, attempt (1 of 3)
Sep 25 22:33:19 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: credentials-service INFO:root:Connecting to DEVSHELL_CLIENT_PORT 40159
Sep 25 22:33:19 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: credentials-service INFO:root:writing to devshell 4 bytes
Sep 25 22:33:19 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: credentials-service INFO:root:read from devshell 293 bytes
Sep 25 22:33:19 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: credentials-service INFO:root:Closing devshell forwarding connection.
Sep 25 22:33:19 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: credentials-service INFO:root:Closing client connection.
Sep 25 22:35:01 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 CRON[1774]: (root) CMD (/google/scripts/gcloud_docker_auth.sh)
Sep 25 22:37:10 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service INFO:root:saw no newline in the first 6 bytes Retrying...(1$
Sep 25 22:37:14 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service INFO:root:Error, could not connect to devshell. Retrying...$
Sep 25 22:37:22 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service ERROR:root:Error, could not connect to devshell. Giving up.
Sep 25 22:37:22 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service Traceback (most recent call last):
Sep 25 22:37:22 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service File "/google/credentials/control_server.py", line 110, i$
Sep 25 22:37:22 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service self.hanging_socket.connect(('localhost', self.server_p$
Sep 25 22:37:22 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service File "/usr/lib/python2.7/socket.py", line 224, in meth
Sep 25 22:37:22 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service return getattr(self._sock,name)(*args)
Sep 25 22:37:22 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service error: [Errno 111] Connection refused
Sep 25 22:37:22 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: 2017-09-25 22:37:22,640 INFO exited: control-command-service (exit status 0; expect$
Sep 25 22:37:23 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: 2017-09-25 22:37:23,642 INFO spawned: 'control-command-service' with pid 1801
Sep 25 22:37:23 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service INFO:root:Error, could not connect to devshell. Retrying...$
Sep 25 22:37:23 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service INFO:root:Error, could not connect to devshell. Retrying...$
Sep 25 22:37:24 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: 2017-09-25 22:37:24,705 INFO success: control-command-service entered RUNNING state$
Sep 25 22:37:27 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service INFO:root:Error, could not connect to devshell. Retrying...$
Sep 25 22:37:27 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service INFO:root:Error, could not connect to devshell. Retrying...$
Sep 25 22:37:34 cs-6000-devshell-vm-c72ffc0b-5c39-48a6-854c-fce64f031c54-41 supervisord: control-command-service INFO:root:Executing health check.
我有类似的问题,在我的情况下,根本原因是我的VM是配置的SSH密钥不能在VM重启后继续存在(一旦VM实例重新启动它们就会从VM配置中消失)。
不太确定这是什么原因,但我的谦虚理论是默认情况下SSH kyes直接存储在启动盘上(而不是持久卷上),在我的情况下,VM已被Delete boot disk when instance is deleted
配置了Delete boot disk when instance is deleted
启用操作,我猜这个功能在重启后以某种方式被触发,这意味着删除了启动盘后SSH密钥丢失了。
您的问题可能是来宾环境。
{#! / bin / bash useradd -G sudo USERNAME echo'USERNAME:PASSWORD'| chpasswd的}
然后在实例内部,您需要通过验证访客环境来获取不起作用的实例:
首先:如果列出以下这些行,请查看串行控制台:
第二步:验证是否安装了guest虚拟机环境的软件包在串行输出中运行命令
apt list --installed | grep google-compute
它应列出以下行: - google-compute-engine - google-compute-engine-oslogin - python-google-compute-engine - python3-google-compute-engine
第三:您需要通过运行此命令来验证guest虚拟机环境的所有服务是否都在运行:
sudo systemctl list-unit-files | grep google | grep enabled
它应列出以下行:
如果根据上述情况有时不同,则可能需要重新启动服务或安装Guest环境
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.