如何从另一个gce VM切换一个gce VM [英] How to ssh a gce VM from another gce VM

查看:120
本文介绍了如何从另一个gce VM切换一个gce VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了两个GCE VM.
风暴1:10.128.0.4
storm2:10.128.0.5

现在,我想在 storm2 上使用ssh storm1 .

storm1 上的 ssh 10.128.0.5 时,我得到信息权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic)

要实现此目标的步骤是什么?或一些教程?

以前,我知道如何从本地计算机SSH Linux虚拟机.

解决方案

  • 步骤1:将 OpenSSH公钥应用于您的 GCP控制台项目或实例
    (

  • 在GCP控制台中将生成的 OpenSSH公共密钥添加到 SSH密钥(不是元数据).

  • 步骤2:将 OpenSSH私钥文件复制到 VMstorm1 〜/.ssh 文件夹中.

  • 第3步:在 VMstorm1 的终端中,使用 ssh 命令和您的 OpenSSH私钥文件连接到您的实例 VM storm2 .
    ssh -i [PATH_TO_PRIVATE_KEY] [USERNAME] @ [INTERNAL_IP_ADDRESS]
    (

  • 提示3:我认为,Step1将导致将 OpenSSH公钥添加到GCP中所有VM的〜/.ssh/authorized_keys 文件中项目.

  • I've created two GCE VMs.
    storm1:10.128.0.4
    storm2:10.128.0.5

    Now I want to ssh storm1 on storm2.

    When ssh 10.128.0.5 on storm1, I got info Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

    What're the steps to achieve this? or some tutorials?

    Previously, I've known how to ssh a linux VM from my local computer.

    解决方案

    • Step1: Apply a OpenSSH public key to your GCP Console project or instance
      (Refer to: Adding or removing project-wide public SSH keys)

      • For example, using Putty Key Generator to generate OpenSSH public/private pair keys.

      • Add the generated OpenSSH public key to SSH keys (not Metadata) in GCP console.

    • Step2: Copy the OpenSSH private key file to ~/.ssh folder of VM storm1.

    • Step3: In a terminal of VM storm1, use the ssh command and your OpenSSH private key file to connect to your instance VM storm2.
      ssh -i [PATH_TO_PRIVATE_KEY] [USERNAME]@[INTERNAL_IP_ADDRESS]
      (Refer to: Connecting using third-party tools)

    Tips:

    • Tips1: If you want to use ssh 10.128.0.5 directly, not specifying the OpenSSH private key file, you can change the name of OpenSSH private key file to id_rsa.
    • Tips2: Identity Putty public key and OpenSSH public key, Putty private key and OpenSSH private key.

    • Tip3: In my opinion, the Step1 will result in adding the OpenSSH public key to ~/.ssh/authorized_keys file of all VMs in the GCP project.

    这篇关于如何从另一个gce VM切换一个gce VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆