gpt4 book ai didi

linux - 重置 Google Compute 引擎 VM 无法通过 SSH 进入实例

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:38:32 25 4
gpt4 key购买 nike

我使用过去 3 年的 Google Compute Engine VM 实例。使用 Putty 我生成了私钥和公钥。在实例 SSH 元数据中添加了公钥。

因此,使用私钥,我可以使用安装在本地计算机上的 gcloud SDK ssh。此外,我还可以通过 PHPSTROM 和 SFTP FileZilla 访问 GCE VM 实例。

最近重置 VM 实例后,我无法通过 SSH 连接。

我的本地 Gcloud SDK Shell 日志:

C:\Users\admin>gcloud init

 Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [default] are:
compute:
region: asia-east1
zone: asia-east1-a
core:
account: user@example.com
disable_usage_reporting: 'True'
project: instance-1

Pick configuration to use:
[1] Re-initialize this configuration [default] with new settings
[2] Create a new configuration
Please enter your numeric choice: 1

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
Reachability Check passed.
Network diagnostic (1/1 checks) passed.

Choose the account you would like to use to perform operations for
this configuration:
[1] user@example.com
[2] Log in with a new account
Please enter your numeric choice: 1

You are logged in as: [user@example.com].

Pick cloud project to use:
[1] instance-2
[2] instance-1
[3] Create a new project
Please enter numeric choice or text value (must exactly match list
item): 2

Your current project has been set to: [instance-1].

Your project default Compute Engine zone has been set to [asia-east1-a].
You can change it by running [gcloud config set compute/zone NAME].

Your project default Compute Engine region has been set to [asia-east1].
You can change it by running [gcloud config set compute/region NAME].

Your Google Cloud SDK is configured and ready to use!

* Commands that require authentication will use user@example.com by default
* Commands will reference project `instance-1` by default
* Compute Engine commands will use region `asia-east1` by default
* Compute Engine commands will use zone `asia-east1-a` by default

Run `gcloud help config` to learn how to change individual settings

This gcloud configuration is called [default]. You can create additional configurations if you work with multiple accounts and/or projects.
Run `gcloud topic configurations` to learn more.

Some things to try next:

* Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command.
* Run `gcloud topic -h` to learn about advanced features of the SDK like arg files and output formatting

C:\Users\admin>ssh-keygen

 Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/admin/.ssh/id_rsa): 1
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in 1.
Your public key has been saved in 1.pub.
The key fingerprint is:
SHA256:weTBQM1j92Lx7iCtubzAZ2+4a5PHron3FDRIyOmb1iY admin@admin-PC
The key's randomart image is:
#ERROR!
| ooB+ |
| +=*oo |
| . .=oo+ |
| . oo.o |
| +So.o |
| .E + o.. |
| .oooB.o |
| *O++ . |
| .oO%+ |
#ERROR!

C:\Users\admin>gcloud compute ssh lamp-bafs

 WARNING: The PuTTY PPK SSH key file for gcloud does not exist.
WARNING: The public SSH key file for gcloud does not exist.
WARNING: The private SSH key file for gcloud does not exist.
WARNING: You do not have an SSH key for gcloud.
WARNING: SSH keygen will be executed to generate a key.
This tool needs to create the directory [C:\Users\admin\.ssh] before
being able to generate SSH keys.

Do you want to continue (Y/n)? Y

Updating project ssh metadata.../Updated [https://www.googleapis.com/compute/v1/projects/instance-1].
Updating project ssh metadata...done.
Waiting for SSH key to propagate.
FATAL ERROR: Network error: Connection timed out
ERROR: (gcloud.compute.ssh) Could not SSH into the instance. It is possible that your SSH key has not propagated to the instance yet. Try running this command again. If you still cannot connect, verify that the firewall and instance are set to accept ssh traffic.

我遇到了上述问题。所以我按照下面的图片步骤进行操作

enter image description here

我在 Gcloud SDK Shell 中运行了以下命令

C:\Users\admin>gcloud compute ssh lamp-bafs

我在 PuTTy 中遇到网络:连接超时问题

enter image description here

我找不到解决方案 SSH via Gcloud SDK Shell, Using Public key to connect VM instance via PhpStrom.我不知道我错过了什么防火墙阻止或任何其他新进程。

请帮忙解决这个问题

最佳答案

“连接超时”意味着问题不是您使用了错误的 key 。相反,它意味着:

  1. 操作系统本身已经崩溃,例如启动失败
  2. SSH 守护进程 (sshd) 未在机器上运行
  3. 有防火墙(GCP 或 iptables)阻止您访问实例。

如果您查看您实例的串行控制台(您应该从您的 VM 的 Cloud Console 页面找到指向它的链接),日志应该会为您提供线索,告诉您哪些是错误的。

如果您无法通过这种方式找到/解决问题,我建议您制作实例磁盘的快照,从该快照创建一个新磁盘,从一个新的 debian 镜像创建一个新实例,并将该磁盘作为辅助磁盘.然后,您可以使用该新实例来修复磁盘或恢复数据。

关于linux - 重置 Google Compute 引擎 VM 无法通过 SSH 进入实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45650048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com