Help us understand the problem. What is going on with this article?

gceにローカルからgcloudで接続できなくなった場合、そうubuntuで。

More than 3 years have passed since last update.

gceのVMにgcloudで接続できなくなった時

  • gcloudと書いてるけど、sshでも一緒かもしれない、きっと一緒だ
  • ubuntuと書いてるけど、きっと他のlinuxでも一緒かもしれない

gcloudeで接続しようとして下記のエラーが出た場合

junk@junk-VirtualBox:~$ gcloud compute --project "custom-unison-XXXXX" ssh --zone "asia-east1-a" "main"
Warning: Permanently added '104.155.XXX.XXX' (ECDSA) to the list of known hosts.
Permission denied (publickey).
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].

対応

1.ローカルPCの接続ユーザのhome下.ssh内の「google_compute_engine.pub」のファイル内容をコピーする。
※このキーはrsaの公開鍵です

view ~/.ssh/google_compute_engine.pub

2.Webの[Compute Engine]の[VM インスタンス]から対象のVMをクリックしサーバの詳細設定を開く。

image

4.そのサーバのsshに先ほどコピーした公開鍵のテキストを貼り付ける

image

5.[保存]をクリック

6.gcloudで接続してみる。

junk@junk-VirtualBox:~$ gcloud compute --project "custom-unison-XXXXX" ssh --zone "asia-east1-a" "main"
Warning: Permanently added '104.155.XXX.XXX' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.13.0-55-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Sat Jul 18 02:47:16 UTC 2015

  System load:  1.09              Processes:           110
  Usage of /:   3.1% of 98.40GB   Users logged in:     1
  Memory usage: 20%               IP address for eth0: 10.240.67.98
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

New release '14.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Your Hardware Enablement Stack (HWE) is supported until April 2017.

Last login: Sat Jul 18 01:43:57 2015 from 121.110.XX.XXX
junk@main:~$ 

接続できるようになりました!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away