无法连接到Google Cloud [英] Unable to SSH to Google Cloud

查看:1784
本文介绍了无法连接到Google Cloud的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了Google Cloud SDK



思想网络用户界面我创建了一个新实例。我不懂SSH。我按照此处所述的步骤执行操作: https://cloud.google.com/compute/docs/实例#sshkeys



我有Window 7 OS



我检查了防火墙规则, https://cloud.google.com/compute/docs/troubleshooting#ssherrors
我通过Web UI检查了这些数据,发现规则

 default-allow-ssh 0.0.0.0/0 tcp: 22适用于所有目标

我遵循的步骤:
$ b $
(默认浏览器打开并且我授权Google Cloud SDK)
Google SDK Shell输出: gcloud auth login / p>

 保存的应用程序Credentails。您现在被记录为[someuser @ gmail] 
您当前的项目是[some-project -999]。



<2>> gcloud compute ssh my-insta nce --zone us-central1-a
Google SDK Shell输出:

 警告:您没有Google Compute Engine的SSH密钥。 
警告:[C:Program Files \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\执行生成
a键。
生成公钥/私钥rsa密钥对。
输入密码(空密码):
再次输入相同密码:
密钥指纹为:
ssh-rsa 2048 06:73:ac:e8:f2:31 :c8:df:d4:b0:a2:3b:a2:53:6c:09
您的私钥已保存在C:\ Users \ Last Last \.ssh\google_compute_engine中。
您的公钥已保存在C:\ Users \ First Last \.ssh\google_compute_engine.pub。
您的putty密钥已保存在C:\ Users \ First Last \.ssh\google_compute_engine.ppk中。
更新了[https://www.googleapis.com/compute/v1/projects/arctic-depth-863]。
服务器拒绝我们的密钥
致命错误:断开:没有支持的身份验证方法可用(服务器发送:publickey)
服务器拒绝我们的密钥
致命错误:断开连接: (服务器发送:publickey)
服务器拒绝我们的密钥
致命错误:断开:没有支持的身份验证方法可用(服务器发送:publickey)
致命错误:网络错误:软件导致连接中止
致命错误:网络错误:连接超时
错误:(gcloud.compute.ssh)无法连接到实例。有可能您的SSH密钥尚未传播到i
nstance。尝试再次运行此命令。如果仍无法连接,请确认防火墙和实例设置为
以接受ssh流量。

在浏览器的Web UI上,我打开Broser的SSH并导航到.ssh文件夹

  someuser_gmail_com @ my-instance:〜$ cd .ssh 
someuser_gmail_com @ my-instance:〜$ cat authorized_keys
#新增Google
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4OxYxWvIlp ... F7As google-ssh {userName:someuser@gmail.com,expireOn:2015-02-21T23:29:06 + 0000}
#加入Google
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzd ... KRqcUZmvWr = google-ssh {userName:someuser@gmail.com,expireOn:2015-02-21T23: 28:55 + 0000}

在Web用户界面上,我导航到Project的> Compute> Compute Engine>元数据> SSH密码和我看到三条记录

KEY




  • someuser_gmail_com ssh -rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4 ...,edpireOn:2015-02-21T23:29:06 + 0000}

  • someuser_gmail_com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTIt ..., edpireO n:2015-02-21T23:29:06 + 0000}

  • 第一个最后ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAi ... ZkpSpRt6RQ ==第一个最后@ MYPC



在我的本地计算机中,我导航到Users / First Last / .ssh / google_compute_engine.pub,我看到

  ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAit ... mGhUKZRgFZkpSpRt6RQ ==第一个最后@ MYPC 

QUESTIONS:


  • 用户文件夹路径中的空格是否会导致问题(即第一个最后)?

  • 当由Google Cloud SDK创建密钥时,它将注释设置为First Last @ MYPC。这是正确的设置? (我一直在阅读和尝试这个,我猜它应该是someuser @ my-instance-public-IP)



  • When I
    Google Cloud SDK> gcloud compute instances describe my-instance --zone us-central1-a --format yaml

      canIpForward:false 
    creationTimestamp:'2015-02-21T14:53:37.276-08:00'
    disks:
    - autoDelete:true
    boot:true
    deviceName:my-instance
    索引:0
    接口:SCSI
    类型:compute#attachedDisk
    许可证:
    - https://www.googleapis。 com / compute / v1 / projects / ubuntu-os-cloud / global / licenses / ubuntu-1204-precise
    模式:READ_WRITE
    来源:https://www.googleapis.com/compute/v1/ projects / some-project-999 / zones / us-central1-a / disks / my-instance
    type:PERSISTENT
    id:'111812933445597333'
    kind:compute#instance
    machineType:https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a/machineTypes/g1-sm所有
    元数据:
    指纹:w3steEkuQUS =
    类型:计算#元数据
    名称:my-instance
    网络接口:$ b $ - accessConfigs:
    - kind:compute#accessConfig
    名称:外部NAT
    natIP:112.134.99.170
    类型:ONE_TO_ONE_NAT
    名称:nic0
    网络:https://www.googleapis .com / compute / v1 / projects / some-project-999 / global / networks / default
    networkIP:10.356.252.66
    调度:
    automaticRestart:true
    onHostMaintenance:MIGRATE
    selfLink:https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a/instances/my-instance
    serviceAccounts:
    - 电子邮件:78111222333-compute@developer.gserviceaccount.com
    范围:
    - https://www.googleapis.com/auth/devstorage.read_only
    - https://www.googleapis .com / auth / logging.write
    status:RUNNING
    标签:
    指纹:DLYFgkKTlB3 =
    项目:
    - http-server
    区域:https ://www.googleapis.com/compute/v1/p rojects / some-project-999 / zones / us-central1-a

    C:\程序文件\Google\Cloud SDK>


    解决方案

    这是从Windows使用Cloud SDK时的一个已知问题。

    请在[1]下载pageant.exe并使用它来加载您的ppk密钥或使用Putty(可从相同链接下载) [b]

    作为解决方法,您甚至可以将ssh.exe重命名为ssh-bak.exe,并将ssh-term.exe重命名为s: Program Files \Google\Cloud SDK\google-cloud-sdk\bin\sdk\



    链接:

    [1 ] - http://www.chiark.greenend.org.uk/ 〜sgtatham / putty / download.html

    [2] - https://cloud.google.com/compute/docs/console#sshkeys


    I installed the Google Cloud SDK

    Thought Web UI I created a new instance. I am not knowledgeable of SSH. I followed steps as described here: https://cloud.google.com/compute/docs/instances#sshkeys

    I have Window 7 OS

    I checked firewall rules as suggested here: https://cloud.google.com/compute/docs/troubleshooting#ssherrors I checked these through Web UI and found rule

    "default-allow-ssh  0.0.0.0/0   tcp:22  Apply to all targets"
    

    STEPS I FOLLOWED:

    1) > gcloud auth login (default browser opens up and I authorize the Google Cloud SDK) Google SDK Shell outputs:

    "Saved Application Credentails. You are now logged as [someuser@gmail]
    Your current project is [some-project-999]. 
    

    2) > gcloud compute ssh my-instance --zone us-central1-a Google SDK Shell outputs:

    WARNING: You do not have an SSH key for Google Compute Engine.
    WARNING: [C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin\..\bin\sdk\ssh-keygen.EXE] will be executed to generate
     a key.
    Generating public/private rsa key pair.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    The key fingerprint is:
    ssh-rsa 2048 06:73:ac:e8:f2:31:c8:df:d4:b0:a2:3b:a2:53:6c:09
    Your private key has been saved in C:\Users\First Last\.ssh\google_compute_engine.
    Your public key has been saved in C:\Users\First Last\.ssh\google_compute_engine.pub.
    Your putty key has been saved in C:\Users\First Last\.ssh\google_compute_engine.ppk.
    Updated [https://www.googleapis.com/compute/v1/projects/arctic-depth-863].
    Server refused our key
    FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
    Server refused our key
    FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
    Server refused our key
    FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
    FATAL ERROR: Network error: Software caused connection abort
    FATAL ERROR: Network error: Connection timed out
    ERROR: (gcloud.compute.ssh) Could not SSH to the instance.  It is possible that your SSH key has not propagated to the i
    nstance yet. Try running this command again.  If you still cannot connect, verify that the firewall and instance are set
     to accept ssh traffic.
    

    On the browser's Web UI, I open the Broser's SSH and I navigate to .ssh folder

    someuser_gmail_com@my-instance:~$ cd .ssh
    someuser_gmail_com@my-instance:~$ cat authorized_keys
    # Added by Google
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4OxYxWvIlp...F7As google-ssh {"userName":"someuser@gmail.com","expireOn":"2015-02-21T23:29:06+0000"}
    # Added by Google
    ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzd...KRqcUZmvWr= google-ssh {"userName":"someuser@gmail.com","expireOn":"2015-02-21T23:28:55+0000"}
    

    on Web UI, I navigate to Project's > Compute > Compute Engine > Metadata > SSH KEYS and I see three records

    USERNAME KEY

    • someuser_gmail_com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4...", "edpireOn":"2015-02-21T23:29:06+0000"}
    • someuser_gmail_com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTIt...", "edpireOn":"2015-02-21T23:29:06+0000"}
    • First Last ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAi...ZkpSpRt6RQ== First Last@MYPC

    In my local computer, I navigate to Users/First Last/.ssh/google_compute_engine.pub and I see

    ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAit...mGhUKZRgFZkpSpRt6RQ== First Last@MYPC
    

    QUESTIONS:

    • Does white space in the user's folder path causes problems (i.e. "First Last")?
    • When the key is created by the Google Cloud SDK, it sets the comment to First Last@MYPC. Is this the correct setting? (I have been reading and trying this and that and I suspect it should be something like someuser@my-instance-public-IP)

    When I Google Cloud SDK > gcloud compute instances describe my-instance --zone us-central1-a --format yaml

    canIpForward: false
    creationTimestamp: '2015-02-21T14:53:37.276-08:00'
    disks:
    - autoDelete: true
      boot: true
      deviceName: my-instance
      index: 0
      interface: SCSI
      kind: compute#attachedDisk
      licenses:
      - https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1204-precise
      mode: READ_WRITE
      source: https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a/disks/my-instance
      type: PERSISTENT
    id: '111812933445597333'
    kind: compute#instance
    machineType: https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a/machineTypes/g1-small
    metadata:
      fingerprint: w3steEkuQUS=
      kind: compute#metadata
    name: my-instance
    networkInterfaces:
    - accessConfigs:
      - kind: compute#accessConfig
        name: External NAT
        natIP: 112.134.99.170
        type: ONE_TO_ONE_NAT
      name: nic0
      network: https://www.googleapis.com/compute/v1/projects/some-project-999/global/networks/default
      networkIP: 10.356.252.66
    scheduling:
      automaticRestart: true
      onHostMaintenance: MIGRATE
    selfLink: https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a/instances/my-instance
    serviceAccounts:
    - email: 78111222333-compute@developer.gserviceaccount.com
      scopes:
      - https://www.googleapis.com/auth/devstorage.read_only
      - https://www.googleapis.com/auth/logging.write
    status: RUNNING
    tags:
      fingerprint: DLYFgkKTlB3=
      items:
      - http-server
    zone: https://www.googleapis.com/compute/v1/projects/some-project-999/zones/us-central1-a
    
    C:\Program Files\Google\Cloud SDK>
    

    解决方案

    This is a known issue when using Cloud SDK from Windows.

    Please download pageant.exe at [1] and use it to load your ppk key or use Putty (downloadable from the same link) to SSH to instance as documented at [2].

    As a workaround you can even rename ssh.exe to ssh-bak.exe and ssh-term.exe to ssh.exe in C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin\sdk\

    Link:
    [1] - http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
    [2] - https://cloud.google.com/compute/docs/console#sshkeys

    这篇关于无法连接到Google Cloud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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