Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
gcloud在Google云上计算从一个VM到另一个VM的ssh_Ssh_Google Cloud Platform_Google Compute Engine_Gcloud - Fatal编程技术网

gcloud在Google云上计算从一个VM到另一个VM的ssh

gcloud在Google云上计算从一个VM到另一个VM的ssh,ssh,google-cloud-platform,google-compute-engine,gcloud,Ssh,Google Cloud Platform,Google Compute Engine,Gcloud,我正在尝试使用gcloud compute ssh命令从Google云中的另一个VM ssh到一个VM。它失败,并显示以下消息: /usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/compute/lib/base_classes.py:9: DeprecationWarning: the sets module is deprecated import sets Connection timed ou

我正在尝试使用
gcloud compute ssh
命令从Google云中的另一个VM ssh到一个VM。它失败,并显示以下消息:

/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/compute/lib/base_classes.py:9: DeprecationWarning: the sets module is deprecated
  import sets

 Connection timed out
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. See https://cloud.google.com/compute/docs/troubleshooting#ssherrors for troubleshooting hints.

我确保ssh密钥已就位,但仍然无法工作。我在这里遗漏了什么?

有一个假设,您已经预先使用SSH和gcloud连接到外部可见的实例

从本地计算机上,使用以下命令启动ssh代理,以便为您管理密钥:

me@local:~$ eval `ssh-agent`
调用ssh add将gcloud compute公钥从本地计算机加载到代理中,并将其用于所有用于身份验证的ssh命令:

me@local:~$ ssh-add ~/.ssh/google_compute_engine
使用外部IP地址登录实例,同时提供-A参数以启用身份验证代理转发

gcloud compute ssh --ssh-flag="-A" INSTANCE
来源:


我不确定“标志”是否适用,因为它不适用于我,但可能我有不同的操作系统或Gcloud版本,它适用于您。

以下是我在Mac上运行的步骤,用于连接到Google Dataproc主虚拟机,然后从主虚拟机跳到工作虚拟机。我将ssh连接到主VM以获取IP

$gcloud compute ssh cluster-for-cameron-m
警告:已将“104.197.45.35”(ECDSA)永久添加到已知主机的列表中。

然后我退出。我为该主机启用了转发

$nano~/.ssh/config

主机104.197.45.35
货运代理是

我添加了gcloud键。

$ssh add~/.ssh/google\u计算引擎

然后,我通过使用
ssh add-l
列出密钥指纹来验证它是否已添加。我重新连接到主VM并再次运行
ssh add-l
,以验证密钥是否确实已转发。在那之后,连接到worker节点工作得很好


ssh cluster-for-cameron-w-0

关于使用ssh代理转发

由于实例经常在云中创建和销毁,因此(重新创建的)主机指纹会不断变化。如果新指纹与
~/.ssh/known_hosts
不匹配,ssh将自动禁用代理转发。解决办法是:

$  ssh -A -o UserKnownHostsFile=/dev/null ...

在MacOS上,我可以确认以下工作:(1)添加
ssh Add~/.ssh/google\u compute\u引擎
。(2)
gcloud compute--project”“ssh--zone“us-west1-a”--ssh flag=“-a”“”
谢谢,它应该在谷歌文档中,我也在尝试做同样的事情,而--ssh flag=“-a”显然不太清楚