秘密鍵の設定

  • GitHub用に秘密鍵名を変更する(id_rsa => id_rsa.github)
$ vi ~/.ssh/config
Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa.github
    Port 22
  • GitHub接続用の秘密鍵の登録
$ ssh-add ~/.ssh/id_rsa.github
  • ssh-addができない場合の対処法
$ ssh-add ~/.ssh/id_rsa.github
Could not open a connection to your authentication agent.
  • ssh-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の一覧確認
$ ssh-add -l
  • SSH接続確認
$ 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

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2015-09-25 (金) 22:37:47 (3135d)