gpt4 book ai didi

ssh - gcloudcompute ssh 拒绝连接(返回代码 255)

转载 作者:行者123 更新时间:2023-12-02 18:29:55 48 4
gpt4 key购买 nike

我无法通过 ssh 访问由 Google Cloud 命令行工具 (gcloud) 创建的虚拟机实例。

症状:

sudo gcloud compute ssh myuser@ubuntu
ssh: connect to host 104.155.16.104 port 22: Connection refused
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].

我做了什么:

1:验证端口 22 上的防火墙已打开

gcloud compute firewall-rules list

已返回

NAME                    NETWORK  SRC_RANGES    RULES                         SRC_TAGS  TARGET_TAGS
allow-rstudio default 0.0.0.0/0 tcp:8787 allow-rstudio
default-allow-http default 0.0.0.0/0 tcp:80 http-server
default-allow-https default 0.0.0.0/0 tcp:443
https-server
default-allow-icmp default 0.0.0.0/0 icmp
default-allow-internal default 10.128.0.0/9 tcp:0-65535,udp:0-65535,icmp
default-allow-rdp default 0.0.0.0/0 tcp:3389
default-allow-ssh default 0.0.0.0/0 tcp:22

2:更新公钥

ssh-keygen -t rsa -f ~/.ssh/google_compute_engine -C myuser

3:使用新公钥更新元数据

sudo gcloud compute ssh myuser@ubuntu
Updating project ssh metadata...
Updating project ssh metadata...done.
Waiting for SSH key to propagate.

然后,仍然是同样的错误消息:

ssh: connect to host 35.187.38.82 port 22: Connection refused
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].

我应该补充一点,直到今天我都可以访问 ssh,当然,我之前使用过身份验证 gcloud 身份验证登录

来自 Google Cloud 网络界面的 SSH 可以正常工作!那里有什么不同?将不胜感激任何帮助!!

最佳答案

经过长时间的查找,我终于找到了这个棘手问题的根本原因。我希望这能帮助一些陷入绝望的人......

您的 ssh 连接可能被拒绝的原因是,外部 IP 请求的内部路由被意外删除。您可以通过以下方式检查:

gcloud compute routes list

如果这不返回包含以下条目的列表:

default-internet       default     0.0.0.0/0       default-internet-gateway 1000

然后您必须通过以下方式重新创建此条目:

gcloud compute routes create default-internet \
--destination-range 0.0.0.0/0 \
--next-hop-gateway default-internet-gateway

关于ssh - gcloudcompute ssh 拒绝连接(返回代码 255),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45155619/

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