无法连接到gcloud [英] Unable to connect to gcloud
问题描述
我无法连接到Google Cloud虚拟实例.我启动了虚拟实例,并能够使用 gcloud beta Calculation ssh
正常登录.然后,我尝试使用 gcloudcompute scp --recurse< local_source>将文件传输到实例.\<用户名> @<实例>:<远程路径>
I am having trouble connecting to a Google Cloud virtual instance. I started up the virtual instance and was able to login as normal using gcloud beta compute ssh
.
I then tried transferring files to the instance using gcloud compute scp --recurse <local_source> \ <user_name>@<instance>:<remote_path>
我得到了正在更新项目ssh元数据..."的响应,这在尝试传输文件时从未见过.文件传输失败:
I got a response of 'Updating project ssh metadata...', which I have never seen before when trying to transfer files. The file transfer failed:
?\240<username>@<IP>: Permission denied (publickey).
此外,现在我什至无法登录虚拟机.当我尝试登录时,我得到:
In addition, now I am not even able to log into the VM. When I try to log-in I get:
ssh: connect to host <IP> port 22: Operation timed out
ERROR: (gcloud.beta.compute.ssh) [/usr/bin/ssh] exited with return code [255].
据我所知,防火墙规则仍然是默认规则,并且允许通过端口22进行连接.我仍然能够通过浏览器窗口登录实例,但不能从命令行登录.任何帮助将不胜感激!
As far as I can tell, the firewall rules are still the default and allow connections through port 22. I am still able to log in to the instance through the browser window, but not from the command line. Any help would be greatly appreciated!
推荐答案
如果您收到 ssh,则GCP项目中的防火墙规则似乎有问题:连接到主机< IP>端口22:操作超时
错误.
创建一个允许SSH连接的新规则:
Create a new rule that allows for SSH connections:
gcloud compute --project = xxxxxx防火墙规则创建newrulename --direction = INGRESS --priority = 999 --network = default --action = ALLOW --rules = tcp:22 --source-ranges= 0.0.0.0/0
我已将优先级更改为999(高于1000),因此它将覆盖默认优先级(以防万一有规则阻止端口22).
I've changed the priority to 999 (higher than 1000) so it will overwrite the default ones (in case there is a rule that blocks port 22).
之后,再次尝试
After that try the gcloud compute ssh myinstancename
again and it should work as usual.
这篇关于无法连接到gcloud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!