msgraph-sshpubkey
2019-11-09 Takeshi Yaegashi
第三十七回Azureもくもく会@品川
自己紹介
八重樫 剛史 Takeshi Yaegashi
● 株式会社バンダイナムコスタジオ所属
● Linux・Unix・OSS・低レベルなことが好きなエンジニア
● ホームページ・ブログ https://l0w.dev
● 最近の仕事
○ Raspberry Pi を使った IoT 案件 (Go)
○ スマホゲームアプリのサーバ (Go)
○ Azureによる開発者向けインフラ構築 (Python, Ansible, etc.)
● 最近の登壇
○ Microsoft de:code 2019「DT01 ゲームメーカー目線でAzureを(略)」
○ Go Conference 2019 Autumn「Microsoft Graph API Library for Go」
msgraph.go
● Microsoft Graph Client Library for Go
https://github.com/yaegashi/msgraph.go
● Microsoft Graph の各種リソースをGo言語で操作できるライブラリ
○ Azure Active Directory: User, Group, ...
○ Office 365: OneDrive, SharePoint, Outlook, Teams, Excel Workbook, ...
● 様々なGo製インフラツールをMicrosoft Graph対応にできるかもしれない
○ oauth2_proxy, traefik, ...
○ HashiCorp Terraform,Vault, Consul, Packer, …
msgraph.go アプリの例:msgraph-sshpubkey
● https://github.com/yaegashi/msgraph.go/tree/master/cmd/msgraph-sshpubkey
● SSH 公開鍵を Azure AD に登録して Linux VM ログインの認証に利用できる
● 必要なものは 5.6MB の実行ファイルと設定ファイルのみ、導入が容易
/etc/ssh/sshd_config:
AuthorizedKeysCommand /usr/bin/msgraph-sshpubkey -config /etc/msgraph-sshpubkey.json -login %u
AuthorizedKeysCommandUser root
/etc/msgraph-sshpubkey.json:
{
"tenant_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"client_id": "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY",
"client_secret": "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ",
"login_map": {
"yaegashi": "yaegashi@l0wdev.onmicrosoft.com"
}
}
背景:Azure Linux VM のユーザー認証・認可
● Windows VM と比較して、認証統合機能が弱い
● Azure Active Directory 認証を使用してAzure の Linux 仮想マシンにログインする
https://docs.microsoft.com/ja-jp/azure/virtual-machines/linux/login-using-aad
● ユーザー名がUPNになる
yaegashi@l0w.dev
● ソースコードが
公開されていない?
● どうも使いづらい
(コレジャナイ感)
● VMのRBACでアクセス
制御できるのはよい
Package: aadlogin
Status: install ok installed
Priority: extra
Section: default
Installed-Size: 686
Maintainer: Azure AD <azuread@microsoft.com>
Architecture: amd64
Version: 1.0.009820001
Depends: uuid-runtime, libcurl4
Conffiles:
/etc/sudoers.d/aad_admins 108feed92ff2287593d22b83206b82ea
Description: AAD NSS and PAM extensions
License: MIT
Vendor: Microsoft
Homepage: https://azure.com
背景:Azure Linux VM に自分がほしい機能
● ユーザーログインの認証、SSH 公開鍵の管理
○ ユーザーの SSH 公開鍵を Azure AD で管理できる
○ VM ログインに Azure AD に登録した SSH 公開鍵が利用できる
○ ユーザーは自分の SSH 公開鍵の管理が Web や CLI で簡単にできる
● ユーザーログインのアクセス認可
○ Azure AD のグループによるアクセス認可
○ Linux VM RBAC 設定によるアクセス認可
● 類似のソフトウェア http://linyo.ws/octopass
○ GitHub のユーザー・組織情報を利用する
msgraph-sshpubkey もくもく進捗
● 今日できたこと
○ WIP: ユーザーが自分の SSH 公開鍵を管理できる Web アプリの開発
■ React フロントエンドと Go バックエンド、CLIの雛形作成
○ msgraph-sshpubkey リポジトリの公開
https://github.com/yaegashi/msgraph-sshpubkey
● 次にやりたいこと
○ CLI と Web アプリの完成
○ Azure AD グループや RBAC などを利用した認可機能
おわり

msgraph-sshpubkey

  • 1.
  • 2.
    自己紹介 八重樫 剛史 TakeshiYaegashi ● 株式会社バンダイナムコスタジオ所属 ● Linux・Unix・OSS・低レベルなことが好きなエンジニア ● ホームページ・ブログ https://l0w.dev ● 最近の仕事 ○ Raspberry Pi を使った IoT 案件 (Go) ○ スマホゲームアプリのサーバ (Go) ○ Azureによる開発者向けインフラ構築 (Python, Ansible, etc.) ● 最近の登壇 ○ Microsoft de:code 2019「DT01 ゲームメーカー目線でAzureを(略)」 ○ Go Conference 2019 Autumn「Microsoft Graph API Library for Go」
  • 3.
    msgraph.go ● Microsoft GraphClient Library for Go https://github.com/yaegashi/msgraph.go ● Microsoft Graph の各種リソースをGo言語で操作できるライブラリ ○ Azure Active Directory: User, Group, ... ○ Office 365: OneDrive, SharePoint, Outlook, Teams, Excel Workbook, ... ● 様々なGo製インフラツールをMicrosoft Graph対応にできるかもしれない ○ oauth2_proxy, traefik, ... ○ HashiCorp Terraform,Vault, Consul, Packer, …
  • 4.
    msgraph.go アプリの例:msgraph-sshpubkey ● https://github.com/yaegashi/msgraph.go/tree/master/cmd/msgraph-sshpubkey ●SSH 公開鍵を Azure AD に登録して Linux VM ログインの認証に利用できる ● 必要なものは 5.6MB の実行ファイルと設定ファイルのみ、導入が容易 /etc/ssh/sshd_config: AuthorizedKeysCommand /usr/bin/msgraph-sshpubkey -config /etc/msgraph-sshpubkey.json -login %u AuthorizedKeysCommandUser root /etc/msgraph-sshpubkey.json: { "tenant_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "client_id": "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY", "client_secret": "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ", "login_map": { "yaegashi": "[email protected]" } }
  • 5.
    背景:Azure Linux VMのユーザー認証・認可 ● Windows VM と比較して、認証統合機能が弱い ● Azure Active Directory 認証を使用してAzure の Linux 仮想マシンにログインする https://docs.microsoft.com/ja-jp/azure/virtual-machines/linux/login-using-aad ● ユーザー名がUPNになる [email protected] ● ソースコードが 公開されていない? ● どうも使いづらい (コレジャナイ感) ● VMのRBACでアクセス 制御できるのはよい Package: aadlogin Status: install ok installed Priority: extra Section: default Installed-Size: 686 Maintainer: Azure AD <[email protected]> Architecture: amd64 Version: 1.0.009820001 Depends: uuid-runtime, libcurl4 Conffiles: /etc/sudoers.d/aad_admins 108feed92ff2287593d22b83206b82ea Description: AAD NSS and PAM extensions License: MIT Vendor: Microsoft Homepage: https://azure.com
  • 6.
    背景:Azure Linux VMに自分がほしい機能 ● ユーザーログインの認証、SSH 公開鍵の管理 ○ ユーザーの SSH 公開鍵を Azure AD で管理できる ○ VM ログインに Azure AD に登録した SSH 公開鍵が利用できる ○ ユーザーは自分の SSH 公開鍵の管理が Web や CLI で簡単にできる ● ユーザーログインのアクセス認可 ○ Azure AD のグループによるアクセス認可 ○ Linux VM RBAC 設定によるアクセス認可 ● 類似のソフトウェア http://linyo.ws/octopass ○ GitHub のユーザー・組織情報を利用する
  • 7.
    msgraph-sshpubkey もくもく進捗 ● 今日できたこと ○WIP: ユーザーが自分の SSH 公開鍵を管理できる Web アプリの開発 ■ React フロントエンドと Go バックエンド、CLIの雛形作成 ○ msgraph-sshpubkey リポジトリの公開 https://github.com/yaegashi/msgraph-sshpubkey ● 次にやりたいこと ○ CLI と Web アプリの完成 ○ Azure AD グループや RBAC などを利用した認可機能
  • 8.