configファイルで複数SSH接続を管理
会社のgithubと自分のgithubを同じマシンで管理
-
ssh configファイル自分のgithub接続用の設定追加
configHost github_private User git Port 22 HostName github.com IdentityFile ~/.ssh/github/private/id_rsa TCPKeepAlive yes IdentitiesOnly yes
-
git origin追加、ホスト名をgithub_privateをする
$ git remote add origin github_private:#{user-name}/xxxx.git
踏み台サーバー
-
踏み台サーバー経由
shellHost bastion HostName bastion.test.com User test Port 22 IdentityFile ~/.ssh/test/id_rsa ForwardAgent yes Host *.ap-northeast* ProxyCommand ssh bastion -W %h:%p
AWSのEC2サーバー管理
ec2ssh gemを使う
https://github.com/mirakui/ec2ssh
キーの管理
ssh-add
-
秘密キー作成して追加
shell$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com" $ ssh-add ~/.ssh/id_rsa
-
秘密鍵の登録状況の確認
shell$ ssh-add -l
-
キーチェーンへ登録
shell$ ssh-add -K ~/.ssh/test/id_rsa
-
再起動したら、キーチェーンから登録済みのキーを追加
shell$ ssh-add -A