公開鍵によるGitHubと通信
概要
公開鍵を使用してGithubへコミット内容を更新する手順
手順
公開鍵、秘密鍵の作成
メニューから「Git」>「Git Bash」を起動(GitをWindowsでインストールしている場合のみ)
「ssh-keygen」で鍵の配置場所及び、パスフレーズを設定(今回は両方ともデフォルト)
matsumoto@WKPC-MSHIGE1979 ~
$ ssh-keygen -t rsa -C "m_shige1979@hogehoge.jp"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/matsumoto/.ssh/id_rsa):
Created directory '/c/Users/matsumoto/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/matsumoto/.ssh/id_rsa.
Your public key has been saved in /c/Users/matsumoto/.ssh/id_rsa.pub.
The key fingerprint is:
f3:28:b8:d3:35:6b:33:a1:ca:ef:f0:6e:f6:16:81:9b m_shige1979@hogehoge.jp
matsumoto@WKPC-MSHIGE1979 ~
$
.sshディレクトリが作成され、id_rsaとid_rsa.pubが作成されていること
matsumoto@WKPC-MSHIGE1979 ~
$ ls .ssh
id_rsa id_rsa.pub
matsumoto@WKPC-MSHIGE1979 ~
$
Githubに公開鍵を登録
Githubにログインし、アカウントを選択
SSH Keysを選択し、右の「Add SSH Key」をクリック
タイトルとキー情報を設定
認証が切れている場合は再度パスワードを設定して認証
登録が完了した場合はSSHKeysに表示される。
Git Bashでコマンドを押下し、接続を確認する。(※初回のみyes/noの確認を行うこと)
matsumoto@WKPC-MSHIGE1979 ~
$ ssh -T git@github.com
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:63:1b:56:4d:eb:df:a6:48:a5:76:28:2d:36.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
Hi mshige1979! You've successfully authenticated, but GitHub does not provide shell access.
matsumoto@WKPC-MSHIGE1979 ~
$
2回目以降の接続の場合は以下のようになる
matsumoto@WKPC-MSHIGE1979 ~
$ ssh -T git@github.com
Hi mshige1979! You've successfully authenticated, but GitHub does not provide shell access.
matsumoto@WKPC-MSHIGE1979 ~
$
リポジトリ作成の前にユーザーとメールアドレスを変更する
matsumoto@WKPC-MSHIGE1979 ~
$ git config --global user.name "m_shige1979"
matsumoto@WKPC-MSHIGE1979 ~
$ git config --global user.email "m_shige1979@hogehoge.jp"
matsumoto@WKPC-MSHIGE1979 ~
$
リポジトリ作成
画面の「Create a Repository」をクリック
画面のリンクをクリック
リポジトリ情報を設定して、クリックを押下
リポジトリ情報が作成される
TortoiseGitでリポジトリをローカルに作成
ファイルを追加
コミット実行
サーバへプッシュを実行
Githubのユーザー名(メールアドレス)を設定
Githubのパスワードを設定
成功することを確認
Githubにて確認し、コミット内容が反映されていること
最終更新:2012年12月31日 19:00