LoginSignup
0
2

More than 5 years have passed since last update.

git SSH 複数 鍵で 運用

Last updated at Posted at 2017-06-18

SSH key config で複数HOST 運用

git hubなどで複数アカウントを運用したい場合など、ssh key を複数作成したいときなどあるでしょう、

そんな時は下記の方法で対応

Host github.com
  User git <- ユーザー名
  Port 22  <- ポート
  HostName github.com <- (&*_*).oO ドメイン
  IdentityFile ~/.ssh/ami <- ssh-keygen で作成した秘密鍵を指定。
  TCPKeepAlive yes <- 接続状態を継続したい場合:yes 継続しない場合:no
  IdentitiesOnly yes <- IdentityFileが必要な場合:yes 必要ない場合:no
Host shichimi.com
    User git
    Port 22
    HostName github.com
    IdentityFile ~/.ssh/id_rsa
    TCPKeepAlive yes
    IdentitiesOnly yes


上記を.ssh/config ファイルに記述したら、ssh で接続します。

# ssh -T Host で指定した名前を記入
ssh -T git@shichimi.com 

成功すると下記文言が出力されます。
Hi suzuya-shichimi! You've successfully authenticated, but GitHub does not provide shell access.

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2