我是新的谷歌云,我刚刚部署我的第一个实例工作正常,直到昨天,我用最后一次设置电子邮件服务器使用本教程的电子邮件服务器 ,但现在我无法连接在浏览器中的SSH和谷歌云sdk在terminal。
网站运行良好,我不知道发生了什么请帮忙
浏览器中的错误信息
Connection Failed, and we are unable to connect VM on port 22.
terminal中的错误信息
Warning: Permanently added 'xxx.xxx.xxx.xxx' (ECDSA) to the list of known hosts. Permission denied (publickey). ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
串口控制台输出其显示
Jul 8 10:09:26 Instance sshd[10103]: error: Could not load host key:/etc/ssh/ssh_host_ed25519_key Jul 8 10:09:27 Instance sshd[10103]: User username from 0.0.0.0 not allowed because not listed in AllowUsers Jul 8 10:09:27 Instance sshd[10103]: input_userauth_request: invalid user username [preauth] Jul 8 10:09:27 Instance sshd[10103]: Connection closed by 0.0.0.0 [preauth] –
看起来您已经在/etc/ssh/sshd_configconfiguration文件中添加了AllowUsers 。
要解决此问题,您需要将VM实例的启动磁盘作为第二个磁盘附加到健康实例。 安装它,编辑configuration文件并解决问题。
以下是可以解决问题的步骤:
首先,拍摄实例磁盘的快照,以防万一丢失或损坏,您可以恢复磁盘。
在Developers Console中,点击您的实例。 Delete boot disk when instance is deleted ,然后删除实例。 引导磁盘将保留在“磁盘”下,现在可以将磁盘连接到另一个实例。 您也可以使用gcloud命令执行此步骤:
$ gcloud compute instances delete NAME --keep-disks all
现在,将该磁盘作为附加磁盘附加到一个健康的实例。 您可以通过开发人员控制台或使用gcloud命令来执行此操作:
$ gcloud compute instances attach-disk EXAMPLE-INSTANCE --disk DISK --zone ZONE
SSH到你的健康实例。
确定辅助磁盘的位置:
$ ls -l /dev/disk/by-id/google-*
安装磁盘:
$ sudo mkdir /mnt/tmp $ sudo mount /dev/disk/by-id/google-persistent-disk-1-part1 /mnt/tmp
其中google-persistent-disk-1是google-persistent-disk-1的名称
编辑sshd_configconfiguration文件并删除AllowUsers行并保存。
$ sudo nano /mnt/tmp/etc/ssh/sshd_config
现在unmout磁盘:
$ sudo umount /mnt/tmp
将其从VM实例中分离出来。 这可以通过开发人员控制台或使用以下命令完成:
$ gcloud compute instances detach-disk EXAMPLE-INSTANCE --disk DISK
现在使用您的固定启动磁盘创build一个新的实例。