フラミナル

考え方や調べたことを書き殴ります。IT技術系記事多め

GCPで起動したVMインスタンスにgcloudコマンドでSSHをする

Google

備忘。

環境はMacOS

gcloudをダウンロード

ここから gcloud compute  |  Compute Engine Documentation  |  Google Cloud Platform

展開しinstall.shを実行

初期設定

SDKのアップデート

Updates are available for some Cloud SDK components.  To install them,
please run:

と怒られたので、SDKのアップデート

  $ gcloud components update

プロジェクトの設定

あらかじめプロジェクトを作っておくこと(VMに接続するフェーズなら普通はあるか・・・)

$ gcloud config set project プロジェクトID

認証登録(google account)

googleアカウントを使って認証登録

$ gcloud auth login

SSH実行

$ gcloud compute ssh instance-1

No zone specified. Using zone [us-central1-b] for instance: [instance-1].
Warning: Permanently added 'xxxxx' (ECDSA) to the list of known hosts.
Linux instance-1 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
xxxxx@instance-1:~$

成功〜〜