秘密鍵の設定 †
- GitHub用に秘密鍵名を変更する(id_rsa => id_rsa.github)
$ vi ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa.github
Port 22
$ ssh-add ~/.ssh/id_rsa.github
$ ssh-add ~/.ssh/id_rsa.github
Could not open a connection to your authentication agent.
$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/id_rsa.github
Enter passphrase for /home/y.shimojo/.ssh/id_rsa.github:
Identity added: /home/y.shimojo/.ssh/id_rsa.github (/home/y.shimojo/.ssh/id_rsa.github)
- .bash_profileに下記スクリプト追記 ※Cygwin起動時にssh-agentを自動起動しexpectコマンドで対話的にssh-addのパスフレーズを入力
# Start ssh-agent and add authentification keys
eval `ssh-agent -s`
# SSH key passphrase for Sakura
ssh-add /home/y.shimojo/.ssh/id_rsa.sakura
# SSH key passphrase for GitHub and Gitlab
expect -c "
set timeout 5
spawn ssh-add /home/y.shimojo/.ssh/id_rsa.github
expect \"Enter passphrase for .ssh/id_rsa.github:\"
send -- \"[passphrase]\n\"
"
$ ssh-add -l
$ ssh git@github.com
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi yujishimojo! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
- 秘密鍵パスフレーズ変更 ※入力を省いてEnterを押すとパスフレーズ無しに変更
$ ssh-keygen -p
Git初期設定 †
$ git init
$ git add .
$ git commit -m "initial commit"
$ git remote add origin git@github.com:yujishimojo/[repo].git
$ git push -u origin master