Upgrade to Pro — share decks privately, control downloads, hide ads and more …

msgraph-sshpubkey

 msgraph-sshpubkey

第三十七回Azureもくもく会@品川

YAEGASHI Takeshi

November 09, 2019
Tweet

More Decks by YAEGASHI Takeshi

Other Decks in Technology

Transcript

  1. msgraph-sshpubkey
    2019-11-09 Takeshi Yaegashi
    第三十七回Azureもくもく会@品川

    View Slide

  2. 自己紹介
    八重樫 剛史 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」

    View Slide

  3. 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, …

    View Slide

  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]"
    }
    }

    View Slide

  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
    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

    View Slide

  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 のユーザー・組織情報を利用する

    View Slide

  7. msgraph-sshpubkey もくもく進捗
    ● 今日できたこと
    ○ WIP: ユーザーが自分の SSH 公開鍵を管理できる Web アプリの開発
    ■ React フロントエンドと Go バックエンド、CLIの雛形作成
    ○ msgraph-sshpubkey リポジトリの公開
    https://github.com/yaegashi/msgraph-sshpubkey
    ● 次にやりたいこと
    ○ CLI と Web アプリの完成
    ○ Azure AD グループや RBAC などを利用した認可機能

    View Slide

  8. おわり

    View Slide