LoginSignup
14
3

More than 3 years have passed since last update.

IBM Cloud CLI を使ってプライベートエンドポイント経由でログインする

Posted at

リリースノート

以下の通り、v1.3.0 からプライベートエンドポイントを経由した CLI ログインが可能になりました。

Release v1.3.0 · IBM-Cloud/ibm-cloud-cli-release · GitHub
Initial Support of Private Endpoints
As the first step of supporting private endpoints, users can now log into a private endpoint through the CLI:

ibmcloud login -a private.cloud.ibm.com

Note that only 2 regions (us-south and us-east) are supported right now. We're rolling out to more regions. Please stay tuned.

In addition to api, login, target, and logout, most commands under account, billing, iam, resource, and catalog namespaces should work. We will continue to support private endpoints in more commands, and plugins will start to support private endpoints soon.

環境

IBM Cloud にあるサーバーから確認します。

[root@khayama-centos ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

インストール

Docs に従って導入します。

Installing the stand-alone IBM Cloud CLI

[root@khayama-centos ~]# curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
Current platform is linux64. Downloading corresponding IBM Cloud CLI...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   111  100   111    0     0    114      0 --:--:-- --:--:-- --:--:--   114
100 11.5M  100 11.5M    0     0  7536k      0  0:00:01  0:00:01 --:--:-- 7536k
Download complete. Executing installer...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    40  100    40    0     0      6      0  0:00:06  0:00:06 --:--:--    10
Bluemix_CLI/
Bluemix_CLI/bin/
Bluemix_CLI/bin/ibmcloud
Bluemix_CLI/bin/ibmcloud.sig
Bluemix_CLI/bin/NOTICE
Bluemix_CLI/bin/LICENSE
Bluemix_CLI/bin/CF_CLI_Notices.txt
Bluemix_CLI/bin/CF_CLI_SLC_Notices.txt
Bluemix_CLI/autocomplete/
Bluemix_CLI/autocomplete/bash_autocomplete
Bluemix_CLI/autocomplete/zsh_autocomplete
Bluemix_CLI/install
Bluemix_CLI/uninstall
Bluemix_CLI/install_bluemix_cli
Install complete.

バージョン確認

[root@khayama-centos ~]# ibmcloud version
ibmcloud version 1.3.0+4308925-2020-12-16T07:53:49+00:00

事前疎通確認

ルーティングに 166.8.0.0/14 があることを確認します。

[root@khayama-centos ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.0.0.0        10.193.37.129   255.0.0.0       UG        0 0          0 eth0
10.193.37.128   0.0.0.0         255.255.255.192 U         0 0          0 eth0
161.26.0.0      10.193.37.129   255.255.0.0     UG        0 0          0 eth0
166.8.0.0       10.193.37.129   255.252.0.0     UG        0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0

その上で、以下のようなエンドポイントに疎通があるかを確認します。

[root@khayama-centos ~]# ping private.us-south.iam.cloud.ibm.com -c 4
PING private.us-south.iam.cloud.ibm.com (166.9.250.194) 56(84) bytes of data.
64 bytes from c2.fa.09a6.ip4.static.sl-reverse.com (166.9.250.194): icmp_seq=1 ttl=53 time=140 ms
64 bytes from c2.fa.09a6.ip4.static.sl-reverse.com (166.9.250.194): icmp_seq=2 ttl=53 time=140 ms
64 bytes from c2.fa.09a6.ip4.static.sl-reverse.com (166.9.250.194): icmp_seq=3 ttl=53 time=140 ms
64 bytes from c2.fa.09a6.ip4.static.sl-reverse.com (166.9.250.194): icmp_seq=4 ttl=53 time=140 ms

--- private.us-south.iam.cloud.ibm.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 140.594/140.681/140.878/0.473 ms

ログイン

[root@khayama-centos ~]# ibmcloud login -a private.cloud.ibm.com
API エンドポイント: https://private.cloud.ibm.com

Check the regions that have private endpoint enabled at https://cloud.ibm.com/docs/cli?topic=cli-ibm-cli-faq#cli-private-endpoint-faq.
Select a region that has a private endpoint enabled:
1. au-syd
2. in-che
3. jp-osa
4. jp-tok
5. kr-seo
6. eu-de
7. eu-gb
8. ca-tor
9. us-south
10. us-east
数値を入力してください> 9
ターゲットのリージョン us-south


Email> xxxxxxxx@gmail.com

Password> 
認証中です...
OK

アカウントを選択:
1. Y's Account (000000) <-> 1111111
2. K's Account (000000)
数値を入力してください> 1
ターゲットのアカウント Y's Account (000000) <-> 1111111


API エンドポイント:      https://private.cloud.ibm.com   
リージョン:              us-south   
ユーザー:                xxxxxxxx@gmail.com   
アカウント:              Y's Account (000000) <-> 1111111   
リソース・グループ:      リソース・グループがターゲットになっていません。'ibmcloud target -g RESOURCE_GROUP' を使用してください   
CF API エンドポイント:      
組織:                       
スペース:                   

IAM トークンの取得

このようにインターネットへの接続がなくても IAM トークンを取得できます。
このトークンを使って IBM Cloud Object Storage の操作などもインターネットを経由せずにおこなえます。

[root@khayama-centos ~]# ibmcloud iam oauth-tokens
IAM トークン:  Bearer eyJraWQiOiIyMDIwMTIyMTExxxxxxxxxxxx...

参考 : IBM 社員が SSO 認証を使う場合

以下のように最終的に https://idaas.iam.ibm.com/idaas/oidc/endpoint/default/authorize に対してインターネットアクセスが必要になり、インターネット接続なしでは認証できません。

[root@khayama-centos ~]# ibmcloud login -a private.cloud.ibm.com --sso
API エンドポイント: https://private.cloud.ibm.com

Check the regions that have private endpoint enabled at https://cloud.ibm.com/docs/cli?topic=cli-ibm-cli-faq#cli-private-endpoint-faq.
Select a region that has a private endpoint enabled:
1. au-syd
2. in-che
3. jp-osa
4. jp-tok
5. kr-seo
6. eu-de
7. eu-gb
8. ca-tor
9. us-south
10. us-east
数値を入力してください> 9
ターゲットのリージョン us-south


Get a one-time code from https://private.us-south.iam.cloud.ibm.com/identity/passcode to proceed.
デフォルトのブラウザーで URL を開きますか? [Y/n] > 

参考 : Mac で IBM Cloud CLI をアップデート

% ibmcloud update
更新を確認しています...
新規バージョン 1.3.0 が使用可能です。
リリース・ノート: https://github.com/IBM-Cloud/ibm-cloud-cli-release/releases/tag/v1.3.0

今すぐ更新しますか? [Y/n] > Y

バージョン '1.3.0' をインストールしています...
ダウンロードしています...
 12.36 MiB / 12.36 MiB [============================================] 100.00% 0s
12964743 バイトがダウンロードされました
/Users/khayama/.bluemix/tmp/bx_599110017/IBM_Cloud_CLI_1.3.0_macos.tgz に保存されました
Superuser privileges are required to run this script.
Password:
Copying files ...
The installation completed successfully.
To get started, open a terminal window and enter "ibmcloud help". Refer to "http://ibm.biz/cli-auto-completion" if you want to enable auto-completion for zsh or bash.

IBM Cloud CLI has a plug-in framework to extend its capability. To install the recommended plug-ins and dependencies, run the install script from "http://ibm.biz/install-idt". For additional plug-in details, see "http://ibm.biz/install-cli-plugin".

Starting from version 1.0.0, the IBM Cloud CLI no longer bundles the Cloud Foundry CLI by default. To run Cloud Foundry commands via the IBM Cloud CLI, install the Cloud Foundry CLI by using the 'ibmcloud cf install' command.

To uninstall, run "/usr/local/ibmcloud/uninstall"
14
3
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
14
3