昨天,我能够毫无问题地连接到我的虚拟机。今天,当我想连接时,它只是循环显示“将 SSH 密钥传输到虚拟机”。当我进入控制台时,它循环显示相同的内容。
[ 25.428229] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:01 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:15 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 39.234910] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:15 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:23 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 47.503004] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:23 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:36 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 59.781896] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:36 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:51 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 74.833424] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:51 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:59 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 83.592217] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:59 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:13 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 97.555182] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:13 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:22 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 106.502914] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:22 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:36 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 119.896296] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:36 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:45 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 128.957112] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:45 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:00 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 143.811024] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:00 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:08 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 152.070307] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:08 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:19 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 162.842013] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:19 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:38 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 182.018657] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:38 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:47 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 191.222629] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:47 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:55 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 199.263207] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:55 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:27 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 230.928268] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:27 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:35 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 238.824908] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:35 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:47 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 250.926710] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:47 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:58 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 262.463967] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:58 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:13 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 277.107377] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:13 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:26 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 290.104692] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:26 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:42 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 306.256838] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:42 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:13 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 337.130106] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:13 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:21 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 345.671107] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:21 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:43 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 366.956060] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:43 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:54 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 377.735550] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:54 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:13 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 397.431086] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:13 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:25 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 409.300145] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:25 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:44 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 428.298872] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:44 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:06 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 449.817168] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:06 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:24 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 468.097514] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:24 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:35 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 478.724337] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:35 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:46 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 490.143037] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:46 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:00 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 504.095877] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:00 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:10 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 514.511027] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:10 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:28 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 532.547638] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:28 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:37 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 541.349512] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:37 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:48 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 551.846271] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:48 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:07 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 571.265681] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:07 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:15 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 579.655513] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:15 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:27 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 591.267328] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:27 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:38 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 601.824841] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:38 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:44 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 608.365183] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:44 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:57:02 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 625.816933] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:57:02 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:57:11 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[ 634.738381] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:57:11 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
我现在不知道如何连接我的 VM 实例。有人能帮助我吗?
我们要求我提供启动日志,但我不知道如何阅读它们,我把完整的日志放在这里,并提供了一些可能是错误/失败/警告的证据。完整日志(非常长): https://hastebin.com/akipiwupuw.coffeescript
一些错误/失败/警告:
[ 0.362757] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
[ 0.363735] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
Mar 27 09:05:47 winter-lounge ntpd[664]: bind(21) AF_INET6 fe80::4001:aff:fea4:2%2#123 flags 0x11 failed: Cannot assign requested address
Mar 27 09:05:47 winter-lounge ntpd[664]: unable to create socket on eth0 (5) for fe80::4001:aff:fea4:2%2#123
Mar 27 09:05:47 winter-lounge ntpd[664]: failed to init interface for address fe80::4001:aff:fea4:2%2
Mar 27 09:05:46 localhost kernel: [ 0.928475] i8042: Warning: Keylock active
Mar 27 09:05:46 localhost kernel: [ 3.322253] random: 7 urandom warning(s) missed due to ratelimiting
使用“管理元数据中的 SSH 密钥”指南时我遵循的步骤:(我在 Windows 上)
1. Downloaded `puttygen.exe`
2. Used it to create SSH keys pair, with "gurvanbk" as comment
3. Didn't set key passphrase
4. Saved private key on my "Documents" folder
5. Saved public key in the same folder
6. Checked public key format: Good
7. Went to Metadata page
8. Went into the "SSH keys section"
9. Deleted all SSH keys for user "gurvanbk"
10. Added my manually created SSH key (public)
11. Saved
12. Went on my VM instances page
13. Clicked the SSH button
14. Window opened
15. Keeps looping "Creating SSH keys"
答案1
我在您的控制台日志中没有发现任何可疑的东西,并且由于 FTP 连接工作正常,因此该问题与 SSH 连接直接相关。
阻止您登录的问题可能仅限于您的用户帐户。例如,
~/.ssh/authorized_keys
实例上的文件权限可能没有为用户正确设置。尝试使用 gcloud 工具以其他用户身份登录,方法是在 SSH 请求中指定 another-username。gcloud 工具将更新项目的元数据以添加新用户并允许 SSH 访问。
gcloud compute ssh another-username@$PROB_INSTANCE
如果成功,请尝试.ssh
从主帐户中删除文件夹并尝试再次登录 - 它将在您下次登录时自动重新创建。
不要忘记禁用通过控制台登录并删除您尝试通过启动脚本添加的临时用户。
答案2
我看到您有一个似乎是 Linux 的 VM,并且您正在通过 Web 浏览器在 Windows 机器上运行的终端连接到它。
看来您正在研究手动管理虚拟机元数据上的 SSH 密钥,这种方法可能存在风险。正如我们在这些文档中看到的:[1][2][3]。
我们也可以在[4]中读到,这里是其中的摘录:
“当您从元数据中删除用户帐户的所有 SSH 密钥时,Google 管理的用户帐户的授权密钥文件将被删除。”
从我读到的所有评论来看,有人提供了非常好的信息来回答您的问题。
我也想与你们分享这份文件[5]。
问题似乎与您的网络浏览器或其扩展有关。您能分享一下吗?
[1]https://cloud.google.com/sdk/gcloud/reference/compute/instances/remove-metadata
[2]https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys
[3]https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#risks
[4]https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh
答案3
还有一种几乎万无一失的访问虚拟机的方法——串行控制台。
你必须启用串行控制台访问使用控制台或gcloud
命令访问该特定虚拟机:
gcloud compute instances add-metadata instance-name \
--metadata serial-port-enable=TRUE
并使用控制台或以下方式连接到它gcloud
:
https://cloud.google.com/compute/docs/instances/interacting-with-serial-console#connectserialconsole
但是 - 如果你不知道凭证,你可能必须创建它们;最简单的方法是设置启动脚本这将创建我们定义的用户和密码,然后我们可以使用它们登录(通过控制台或稍后通过 SSH)。
示例脚本(用于 Debian VM - 在 RHEL 8 上也同样有效)如下所示:
#! /bin/bash
adduser username
echo 'username:userspass' | chpasswd
usermod -aG google-sudoers username
通过串行控制台连接是最后的方法,但如果其他方法失败,则可以使用这种方法。只有当操作系统出现严重问题(系统磁盘已满、文件损坏等)时,这种方法才会失败。
我已经详细解释了这一点SO 上的另一个此类问题。