本文介绍了浏览器无法通过SSH连接Google Compute Engine实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过ssh连接到GCE。它显示连接失败,并且我们无法连接端口22上的虚拟机。



并且串行控制台输出其显示



7月8日10:09:26实例sshd [10103]:错误:无法加载主机密钥:/ etc / ssh / ssh_host_ed25519_key

Jul 8 10:09 :27实例sshd [10103]:从0.0.0.0开始的用户名不允许,因为未在AllowUsers中列出



Jul 8 10:09:27实例sshd [10103]:input_userauth_request :无效的用户名[preauth] Jul 8 10:09:27 Instance sshd [10103]:连接已关闭0.0.0.0 [preauth] -



昨天工作正常,但今天它显示这个错误。我是GCE的新手。任何建议?

解决方案

更新

我想发布此更新以提及2016年6月发布了一项新功能,您可以在其中启用对串行控制台的交互式访问,以便您可以更轻松地排除未正确引导或无法访问的实例的故障。有关更多信息,请参见与串行控制台进行交互。

----------------------------------- ------------------------------------------------



它看起来像在 / etc / ssh / sshd_config AllowUsers c $ c>配置文件。



要解决此问题,您需要将VM实例的启动磁盘作为第二个磁盘附加到健康实例。安装它,编辑配置文件并解决问题。



以下是解决问题的步骤:


  1. 首先,拍摄实例磁盘的快照,以防万一丢失或损坏发生,您可以恢复磁盘。

  2. $ b
  3. 在Developers Console中,点击您的实例。取消选中实例删除时删除启动盘,然后删除实例。引导磁盘将保留在磁盘下,现在可以将磁盘连接到另一个实例。您还可以使用 gcloud 命令执行此步骤:

      $ gcloud compute实例删除NAME --keep-disks全部


  4. 现在将磁盘连接到一个健康的实例一个额外的磁盘。您可以通过开发人员控制台或使用 gcloud 命令执行此操作:

      $ gcloud compute instances attach-disk示例 - 实例 - 磁盘DISK  - 区域



  5. 确定辅助磁盘的存储位置:

      $ ls -l / dev / disk / by-id / google- * 


  6. 安装磁盘:

      $ sudo mkdir / mnt / tmp 
    $ sudo mount / dev / disk / by-id / google-persistent-disk-1-part1 / mnt / tmp


其中 google-persistent-disk-1 是磁盘的名称


  1. 编辑 sshd_config 配置文件并删除 AllowUsers line并保存它。

      $ sudo nano / mnt / tmp / etc / ssh / sshd_config 

  2. c> $ sudo umount / mnt / tm p


  3. 将其从VM实例中分离出来。这可以通过开发人员控制台或使用以下命令完成:

      $ gcloud计算实例detach-disk示例 - 实例 - disk DISK 


  4. 现在使用您的固定启动磁盘创建一个新实例。



I cannot connect to GCE via ssh. It is showing Connection Failed, and we are unable to connect VM on port 22.

And serial console output its shows

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] –

Yesterday it was working fine, but today it shows this error. I am new to GCE. Any suggestions?

解决方案

UPDATE

I'd like to post this update to mention that on June 2016 a new feature is released where you can enable interactive access to the serial console so you can more easily troubleshoot instances that are not booting properly or that are otherwise inaccessible. See Interacting with the Serial Console for more information.

-----------------------------------------------------------------------------------

It looks like you've added AllowUsers in /etc/ssh/sshd_config configuration file.

To resolve this issue, you'll need to attach the boot disk of your VM instance to a healthy instance as the second disk. Mount it, edit the configuration file and fix the issue.

Here are the steps you can take to resolve the issue:

  1. First of all, take a snapshot of your instance’s disk, in case if a loss or corruption happens you can recover your disk.

  2. In the Developers Console, click on your instance. Uncheck Delete boot disk when instance is deleted and then delete the instance. The boot disk will remain under "Disks", and now you can attach the disk to another instance. You can also do this step using gcloud command:

    $ gcloud compute instances delete NAME --keep-disks all
    

  3. Now attach the disk to a healthy instance as an additional disk. You can do this through the Developers Console or using the gcloud command:

    $ gcloud compute instances attach-disk EXAMPLE-INSTANCE --disk DISK --zone ZONE
    

  4. SSH into your healthy instance.

  5. Determine where the secondary disk lives:

    $ ls -l /dev/disk/by-id/google-*
    

  6. Mount the disk:

    $ sudo mkdir /mnt/tmp
    $ sudo mount /dev/disk/by-id/google-persistent-disk-1-part1 /mnt/tmp
    

Where google-persistent-disk-1 is the name of the disk

  1. Edit sshd_config configuration file and remove AllowUsers line and save it.

    $ sudo nano /mnt/tmp/etc/ssh/sshd_config
    

  2. Now unmout the disk:

    $ sudo umount /mnt/tmp
    

  3. Detach it from the VM instance. This can be done through the Developers Console or using the command below:

    $ gcloud compute instances detach-disk EXAMPLE-INSTANCE --disk DISK
    

  4. Now create a new instance using your fixed boot disk.

这篇关于浏览器无法通过SSH连接Google Compute Engine实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 18:31