LoginSignup
1
2

More than 5 years have passed since last update.

Google Cloud SDKのインストールと Google Cloud Shell への SSH 接続

Last updated at Posted at 2018-06-06

RHEL7 に Google Cloud SDK のインストールし、SSH で Google Cloud Shell へ接続するまでの手順。

実行環境

  • OS: RHEL7
  • python: 2.7.5

インストール

$ tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
       https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOM

$
$ yum install google-cloud-sdk -y

SDK の初期化

$ gcloud init --console-only

::

You must log in to continue. Would you like to log in (Y/n)?  Y

Go to the following link in your browser:

    https://accounts.google.com/xxxxxxxxxxxxxxxxxxxxx←URL にブラウザでアクセス


Enter verification code:←ブラウザで取得したコードを入力。以降はデフォルトのゾーンなどの入力が求められる

SSH 接続

$ gcloud alpha cloud-shell ssh

WEB ブラウザで Google Cloud Shell を使用した場合と異なり、SSH 接続直後はプロジェクトが設定されていないので、以下のコマンドでプロジェクトを設定する。

$ gcloud projects list
PROJECT_ID             NAME              PROJECT_NUMBER
xxxxx                  yyyyy             zzzzz
$ 
$ gcloud config set project <PROJECT_ID>

参考:
* https://cloud.google.com/sdk/docs/quickstart-redhat-centos
* https://cloudplatform-jp.googleblog.com/2018/04/introducing-the-ability-to-connect-to-Cloud-Shell-from-any-terminal.html
* https://cloud.google.com/sdk/gcloud/reference/alpha/cloud-shell/ssh
* https://qiita.com/saber_chica/items/6d3a413ce73aae0f6607
* 参考にさせていただきました。ありがとうございます。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2