Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
.ssh/configを管理する .ssh/configで管理する
Search
Ken’ichiro Oyama
November 03, 2016
Technology
11k
15
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
.ssh/configを管理する .ssh/configで管理する
PHPカンファレンス2016
Ken’ichiro Oyama
November 03, 2016
More Decks by Ken’ichiro Oyama
See All by Ken’ichiro Oyama
Introducing RFC9111 / YAPC::Fukuoka 2025
k1low
2
5.5k
Design and implementation of "Markdown to Google Slides" / phpconfuk 2025
k1low
1
940
analysis パッケージの仕組みの上でMulti linter with configを実現する / Go Conference 2025
k1low
1
780
Flight recorder at the application layer (NOT the FlightRecoder newly added at Go 1.25) / Fukuoka.go #22
k1low
0
170
ソフトウェア開発におけるインターフェイスという考え方 / PHPerKaigi 2025
k1low
12
6.3k
Parsing HCL/CUE / Fukuoka.go #21
k1low
0
11k
実践 net/http Middleware パターン / Kizuku.go Vol.1
k1low
2
450
Cleanup handling in Go / Go Conference 2024
k1low
7
4.1k
CI/CDがあたりまえの今の時代にAPIテスティングツールに求められていること / CI/CD Test Night #7
k1low
18
12k
Other Decks in Technology
See All in Technology
Chainlitで作るお手軽チャットUI
ynt0485
0
280
Lightning近況報告
kozy4324
0
210
小さく始める AI 活用推進 ― 日経電子版 Web チームの事例/nikkei-tech-talk47
nikkei_engineer_recruiting
0
310
Bucharest Tech Week 2026 - Reinventing testing practices in the AI era
edeandrea
PRO
1
170
AIネイティブな開発のサプライチェーンリスク対策 〜激動の開発現場でリスクに立ち向かう〜【ZennFes】
cscengineer
PRO
2
140
Oracle Cloud Infrastructure:2026年6月度サービス・アップデート
oracle4engineer
PRO
0
150
自分が詳しくない領域でAIを使う #プロヒス2026
konifar
18
6k
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
340
When Platform Engineering Meets GenAI
sucitw
0
140
アジャイルな経理と Claude Code と経営の未来
kawaguti
PRO
3
170
SONiC Scale-Up Working Group から探る Scale-UpやUltraEthernet機能の実装方法
ebiken
PRO
2
420
[チョークトーク資料]AWS DevOps Agent を使いこなす / AWS Dev Ops Agent Chalk Talk AWS Summit Japan 2026
kinunori
3
620
Featured
See All Featured
First, design no harm
axbom
PRO
2
1.2k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
420
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
200
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Context Engineering - Making Every Token Count
addyosmani
9
970
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
150
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Transcript
.ssh/configを管理する .ssh/configで管理する Kenʼichiro Oyama Fusic Co.,Ltd. 2016.11.3 1 PHPカンファレンス2016
みなさん SSHしてますか? 2 PHPカンファレンス2016
わたしは SSHしてます 3 PHPカンファレンス2016
?> NEXT PHPカンファレンス2016のテーマ 4 PHPカンファレンス2016
SSHとNEXT 5 PHPカンファレンス2016 FTP SSH + パスワード
SSH + 公開鍵認証 「SSHしたら負け」 <- たぶんここがNEXT Docker、EC2 Run Command、etc “NEXT”ではないですが、 今⽇は”SSH + 公開鍵認証”で少しだけ役に⽴ちそ うな話をします
Who 6 PHPカンファレンス2016
k1LoW Kenʼichiro Oyama @k1LoW Fusic Co.,Ltd. エンジニア
基盤ユニット テックリード GitHub organizations fukuokarb / dotcake / emacs-jp / etc. awspecというAWS⽤のテストツールを作って います https://github.com/k1LoW/awspec 7 PHPカンファレンス2016
普段のわたし 複数のプロジェクト 開発中 運⽤中 複数のサーバ
プロジェクト単位 ロール単位(Web、DB、etc) 本番、ステージング、テスト 8 PHPカンファレンス2016
イメージ 複数のプロジェクトの複数のサーバにSSH 9 PHPカンファレンス2016
~/.ssh/config SSH接続の管理をするための設定ファイル ~/.ssh/configはユーザごとの設定ファイル 10 PHPカンファレンス2016 Host github.com
User git Hostname github.com PreferredAuthentications publickey IdentityFile ~/.ssh/github_rsa
/home/k1low/.ssh/config 管理しているサーバへSSH接続するための設定 を記載 秘密鍵も .ssh/ 以下に配置 プロジェクトごと、ロールごと、サーバごとな
どで分けることが多い id_rsaは使わない 秘密鍵だけでなく、その他の接続設定も重要 HostnameやUser ProxyCommandとか 11 PHPカンファレンス2016
.ssh/config どうやって管理していますか? 12 PHPカンファレンス2016
.ssh/configの管理 configのバックアップ/リストア 秘密鍵のバックアップ/リストア サーバ接続情報の追加/削除 チームメンバーへの共有
踏み台サーバなど他サーバへの設置 13 PHPカンファレンス2016
configと秘密鍵に分かれていて ⾯倒 14 PHPカンファレンス2016
configは分割できないので メンバーへの共有も⾯倒 15 PHPカンファレンス2016
今のconfigとバックアップした configのマージも⾯倒 16 PHPカンファレンス2016
sconb 17 PHPカンファレンス2016
sconb “Ssh CONfig Buckup tool” .ssh/config専⽤のバックアップツール https://github.com/k1LoW/sconb
gem install sconb でインストール ※本⽇も⼤変お世話になっているCONBUとは無関係です 18 PHPカンファレンス2016
使い⽅ 19 PHPカンファレンス2016
バックアップ 20 PHPカンファレンス2016 $ sconb dump > ssh_config.json $ cat
ssh_config.json { "github.com": { "Host": "github.com", "User": "git", "Hostname": "github.com", "PreferredAuthentications": "publickey", "IdentityFile": [ "~/.ssh/github_rsa" ] }, ...
絞り込んでバックアップ 21 PHPカンファレンス2016 $ sconb dump example > ssh_config.json $ cat
ssh_config.json { ”example.com": { "Host": ”example.com", "User": ”k1low", "Hostname": ”dev.example.com", "PreferredAuthentications": "publickey", "IdentityFile": [ "~/.ssh/example_rsa" ] } }
リストア 22 PHPカンファレンス2016 $ sconb restore < ssh_config.json Host github.com
User git Hostname github.com PreferredAuthentications publickey IdentityFile ~/.ssh/github_rsa ... $ sconb restore < ssh_config.json > ~/.ssh/cofing
秘密鍵も含めて1ファイル化 23 PHPカンファレンス2016 $ sconb dump --all > ssh_config_with_key.json $
cat ssh_config_with_key.json { "github.com": { "Host": "github.com", "User": "git", "Hostname": "github.com", "PreferredAuthentications": "publickey", "IdentityFile": [ "~/.ssh/github_rsa" ], "IdentityFileContent": [ "-----BEGIN RSA PRIVATE KEY-----\nMIIEpXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX... ] }, ...
秘密鍵のリストア 24 PHPカンファレンス2016 $ sconb keyregen < ssh_config_with_key.json Regenerate ~/.ssh/github_rsa
... ...
つまり ssh_config <-> JSON のコンバータ 25 PHPカンファレンス2016
パイプで各種UNIXコマンドとも 連携できる 26 PHPカンファレンス2016
jqを使ったssh_confg.jsonのマージ jq: JSONをいい感じに操作できるコマンド 27 PHPカンファレンス2016 $ jq -s '.[0]
+ .[1]’ a.json b.json | sconb restore > ~/.ssh/config
.ssh/configを管理する sconbはおいしい 28 PHPカンファレンス2016
別の視点から 29 PHPカンファレンス2016
普段のわたし(再掲) 複数のプロジェクト 開発中 運⽤中 複数のサーバ
プロジェクト単位 ロール単位(Web、DB、etc) 本番、ステージング、テスト 30 PHPカンファレンス2016
イメージ(再掲) 複数のプロジェクトの複数のサーバにSSH 31 PHPカンファレンス2016
突然の◯penSSLの脆弱性発表 32 PHPカンファレンス2016
インベントリ情報 「サーバにイントールされているパッケージの バージョン⼀覧を再度確認して欲しい」 現在稼働しているサーバ数⼗台 まったく別の時期にまったく別のサービスを 構築している
全部SSHでログインして確認。。。??そして その後まとめるの。。。? ツラみがある。。。 33 PHPカンファレンス2016
34 koma PHPカンファレンス2016
koma エージェントレスでリモートホストのインベン トリ情報を収集するツール https://github.com/k1LoW/koma 類似ツール: ohai /
facter gem install koma でインストール `ssh` を `koma ssh` に変えるだけで、リモ ートホストのインベントリ情報をJSONで取得 できる 35 PHPカンファレンス2016
koma ssh 36 PHPカンファレンス2016 $ koma ssh example.com {
"memory": { "swap": { "cached": "652kB", "total": "2097148kB", "free": "2091376kB" }, "total": "1019956kB", "free": "255104kB", "buffers": "310644kB", "cached": "185748kB", ...
koma keys (収集できるインベントリ情報) memory ec2 (disabled) hostname
domain fqdn platform platform_version filesystem cpu virtualization kernel block_device package user group service PHPカンファレンス2016 37
koma run-command 38 PHPカンファレンス2016 $ koma run-command example.com,example.jp uptime {
"example.com": { "uptime": { "exit_signal": null, "exit_status": 0, "stderr": "", "stdout": " 00:18:10 up 337 days, 4:51, 1 user, load average: 0.08, 0.02, 0.01\n" } }, "example.jp": { "uptime": { ...
そう、.ssh/configが設定されて いればね! 39 PHPカンファレンス2016
.ssh/configで管理する 40 PHPカンファレンス2016
ssh_config形式で管理する .ssh/configで管理する 41 PHPカンファレンス2016
koma with ssh_config komaはssh_config形式のフォーマットを STDINから読み込んで実⾏することができる Vagrant上のOSのcpu情報を取得 sconbをでHostをフィルタリング
42 PHPカンファレンス2016 $ vagrant ssh-config | koma ssh --key cpu $ sconb dump dev.* | sconb restore | koma ssh
Vuls 43 PHPカンファレンス2016
Vuls “VULnerability Scanner” バルス Linux/FreeBSD向けの脆弱性スキャンツール Ubuntu、Debian、CentOS、Amazon
Linux、RHELに対応 標準のTUIだけでなくVulsRepoというWebビューワもある NVDやJVNの脆弱性情報などを使⽤してスキャン スキャン対象のサーバーへは “SSH” で接続 TOMLで設定を記述 44 PHPカンファレンス2016
SSH。。。だと。。? 45 PHPカンファレンス2016
ssh_config_to_vuls_config 46 PHPカンファレンス2016
ssh_config_to_vuls_config ssh_config形式をVuls⽤のTOMLファイル形式 に変換 sc2vcコマンド https://github.com/k1LoW/ssh_config_to_vuls_config gem
install ssh_config_to_vuls_config でインストール (当然)sconbでフィルタリングも可能 47 PHPカンファレンス2016 $ cat ~/.ssh/config | sc2vc > vuls_config.toml $ sconb dump dev.* | sconb restore | sc2vc > filtered_config.toml
.ssh/config -> JSON JSON -> .ssh/config JSON -> koma JSON
-> Vuls 48 PHPカンファレンス2016
NEXT 49 PHPカンファレンス2016
ssh_configファイルを集約すれば サーバインベントリ情報も 脆弱性情報も 管理できるのでは? 50 PHPカンファレンス2016
こんなサーバを 51 PHPカンファレンス2016
.ssh/configで管理 52 PHPカンファレンス2016
komad (仮) sconbなJSONをAPI or SCP経由で登録 ssh_config + komaでサーバインベントリ情報
を収集管理 ssh_config + Vulsで脆弱性情報を収集管理 koma run-commandでSSHを通じた外形監視 ちょっと変わったサーバ管理/監視システムが できそう 53 PHPカンファレンス2016
.ssh/configで管理する 54 PHPカンファレンス2016
まとめ 55 PHPカンファレンス2016
まとめ .ssh/configをsconbでJSON形式にすることで 管理容易性、再利⽤性を向上 .ssh/configやssh_config形式のフォーマット を⼊⼒として動くエージェントレスなサーバイ ンベントリ収集ツール koma
Vulsの設定の元として.ssh/configの活⽤ ssh_configを活⽤したサーバ管理/監視システ ムkomad(仮)の可能性 56 PHPカンファレンス2016
さっそく .ssh/configを整理しましょう 古い設定、残っていませんか? 57 PHPカンファレンス2016
Thank you! Fusicはテクノロジーが 好きなエンジニアを募集しています https://fusic.github.io 58
?> 59 PHPカンファレンス2016
NEXT 60 PHPカンファレンス2016
イメージ(再掲) 複数のプロジェクトの複数のサーバにSSH 61 PHPカンファレンス2016
サーバのユーザを管理したい どのサーバにどのユーザがSSHログインできる のか 簡単なものでいい ある程度でいい もしくはSSHログインできる情報をもらえるよ
うにしたい 公開鍵とか秘密鍵とかの管理 62 PHPカンファレンス2016
⼀般的な⽅法 63 PHPカンファレンス2016
PAM Pluggable Authentication Module PAMを使ってユーザ管理サーバ(認証基盤)に 認証の要求をもらう ADとかLDAPが⼀般的らしい
ただ個⼈的にはSTNS推し シンプル 設定がTOML 認証サーバ側をサーバレスにできそう http://qiita.com/shogomuranushi/items/ f09fcdeb146b45452403 新イケメンことP⼭さん(@pyama86)が開発している 64 PHPカンファレンス2016
だかしかし 65 PHPカンファレンス2016
プロジェクトを横断できない 完全弊社都合 66 PHPカンファレンス2016
komad(仮)がssh_configを 払い出したらどうだろう 67 PHPカンファレンス2016
komad(仮)にもらう API経由でssh_config.jsonをもらう 68 PHPカンファレンス2016
どうでしょう。。? イビツなのは承知 komad(仮)サーバの運⽤。。。 無理があるか。。。 69 PHPカンファレンス2016
Thank you! Fusicはテクノロジーが 好きなエンジニアを募集しています https://fusic.github.io 70