Red Hat Training

A Red Hat training course is available for RHEL 8

5.5.3. 为 Google Compute Engine 创建 SSH 密钥

执行以下流程,通过 GCE 生成 SSH 密钥并注册 SSH 密钥,以便您可以使用其公共 IP 地址直接 SSH 到实例。

流程

  1. 使用 ssh-keygen 命令来生成用于 GCE 的 SSH 密钥对。

    # ssh-keygen -t rsa -f ~/.ssh/google_compute_engine
  2. GCP Console Dashboard 页面 中,点击 Google Cloud Console banner 左侧的 Navigation 菜单,并选择 Compute Engine,然后选择 Metadata
  3. SSH Keys,然后点 Edit
  4. 输入 ~/.ssh/google_compute_engine.pub 文件中生成的结果,然后单击 Save

    现在,您可以使用标准 SSH 连接到实例。

    # ssh -i ~/.ssh/google_compute_engine <username>@<instance_external_ip>
注意

您可以运行 gcloud compute config-ssh 命令,使用实例的别名来填充配置文件。别名允许按实例名称简单的 SSH 连接。有关 gcloud compute config-ssh 命令的详情,请参考 gcloud compute config-ssh