# Git ssh複数key設定メモ
- githab,gitlabの両方のSSH接続した際の設定メモ
###### tags: `kreisacademy`
**<設定手順>**
```git
# 1.githab用の秘密鍵作成 .ssh下に作成
$ ssh-keygen -t rsa -f ~/.ssh/kreisGitHabKey -C "githab用"
# 2.gitlab用の秘密鍵作成 .ssh下に作成
$ ssh-keygen -t rsa -f ~/.ssh/kreisGitlabKey -C "gitlab用"
# 3. github,githabにkey登録 ※ssh settingより登録
# 4. configファイルを作成。
$cat ./ssh/config
Host gothub
HostName github.com
IdentityFile ~/.ssh/kreisGitHabKey
IdentitiesOnly yes
Host gitlab
HostName gitlab.com
IdentityFile ˜/.ssh/kreisGitlabKey
IdentitiesOnly yes
5. 接続確認
$ ssh git@gitlab.com
PTY allocation request failed on channel 0
Welcome to GitLab, @ichio-kondo!
Connection to gitlab.com closed.
$ ssh git@github.com
PTY allocation request failed on channel 0
Hi ichio-kondo! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
#Permission denied が出た場合
$ssh-add <秘密鍵名>
```