Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
.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.7k
Design and implementation of "Markdown to Google Slides" / phpconfuk 2025
k1low
1
1.1k
analysis パッケージの仕組みの上でMulti linter with configを実現する / Go Conference 2025
k1low
1
890
Flight recorder at the application layer (NOT the FlightRecoder newly added at Go 1.25) / Fukuoka.go #22
k1low
0
200
ソフトウェア開発におけるインターフェイスという考え方 / PHPerKaigi 2025
k1low
12
6.4k
Parsing HCL/CUE / Fukuoka.go #21
k1low
0
11k
実践 net/http Middleware パターン / Kizuku.go Vol.1
k1low
2
470
Cleanup handling in Go / Go Conference 2024
k1low
7
4.2k
CI/CDがあたりまえの今の時代にAPIテスティングツールに求められていること / CI/CD Test Night #7
k1low
18
12k
Other Decks in Technology
See All in Technology
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
4
3.3k
AIで社員の自主発信に広報目線を組み込む
_mossann_t
0
130
GoのInterface内部構造から学ぶ!最高パフォーマンスを出すコード設計
yappli_developers
0
190
「守り」で活用するオンデバイスLLM 〜写ってはいけないを総力戦で防ぐ〜 / iOSDC Japan 2026
nakamuuu
0
180
Deployment の 先にある AI Agent 基盤 - kagent vNext、Agent Substrate、Hermes から読み解く Agent Runtime の現在地 / k8s-matsuri-2-ai-agent-platform-amsy810
masayaaoyama
4
670
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
3
900
SREの視点で考えるSIEM活用術 〜AWS環境でのセキュリティ強化〜
cscengineer
PRO
0
130
今話題のAI「Jev」って何? 宇宙最速で学ぶ会
minorun365
PRO
30
17k
WordPressの脆弱性対策何をすべき?
masakawai
0
110
俺の仕事は AIに奪われないし、たぶんその BIも要らない
hikaruri
0
520
Issue 駆動でスペシャリストの意図を届ける、AI 実装のアクセシビリティ向上
thkt
0
120
EventBridge に「合流」はない ― サーバーレスのワークフローを育てるということ / No Join in EventBridge
yusukeshimizu
2
260
Featured
See All Featured
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
30 Presentation Tips
portentint
PRO
1
400
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
610
A Soul's Torment
seathinner
8
3.6k
Navigating Weather and Climate Data
rabernat
0
520
Product Roadmaps are Hard
iamctodd
55
13k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Technical Leadership for Architectural Decision Making
baasie
3
570
How to Ace a Technical Interview
jacobian
281
24k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
500
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