1つのマシンで複数のGitアカウントを使用する

新しいSSH鍵の作成

% ssh-keygen -t rsa -f ~/.ssh/xxx -C "some comment"
% cat .ssh/xxx.pub // 鍵をGithubへ貼り付け
% sudo vi ~/.ssh/config

config ファイルへ以下を記載する.

Host xxx
    User yyy
    HostName github.com
    IdentityFile ~/.ssh/xxx


ssh接続を行い, 認証させる.

% ssh c-onnexio // Gitへ認証させる
The authenticity of host 'github.com (xxx.xx.xxx.xxx)' can't be established.
RSA key fingerprint is SHAxxx:xxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,xxx.xx.xxx.xxx' (RSA) to the list of known hosts.
Saving password to keychain failed
Identity added: /Users/user/.ssh/c-onnexio ((null))
PTY allocation request failed on channel 0
Hi c-onnexio! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.


Gitコマンドを使う

% git clone git@xxx:{アカウント}/{リポジトリ}.git // clone
% git remote add origin git@xxx:{アカウント}/{リポジトリ}.git //remote add