前回までに bitbucket や GitHub への SSH アクセスに利用するキーの生成や毎回パスワードを入力せずにすむ仕掛けを .bashrc へ追加するところまでできました。
今回は実際に SSH での接続ができるかをテストしてみましょう。
…とはいっても簡単で、Git Bash から ssh -T [email protected] と入力するだけです。
SSHでの接続テスト
Welcome to Git (version 1.9.2-preview20140411)
Run 'git help git' to display the help index.
Run 'git help ' to display help for specific commands.
[email protected] ~
$ cd .ssh
[email protected] ~/.ssh
$ ls
config environment id_rsa id_rsa.pub
[email protected] ~/.ssh
$ vi config
[email protected] ~
$ cat .ssh/config
Host bitbucket.org
IdentityFile ~/.ssh/id_rsa
[email protected] ~
$
失敗している例 その1
[email protected] ~/.ssh
$ ssh -T [email protected]
/c/Users/daisuke/.ssh/config: line 2: Bad configuration option: IndentityFile
/c/Users/daisuke/.ssh/config: terminating, 1 bad configuration options
※ この失敗例では、config の内容に typo があって、IndentityFile になってるので 2 行目でこけます。
IdentityFile が正しいです。
失敗している例 その2
[email protected] ~
$ ssh -T [email protected]
Warning: Permanently added the RSA host key for IP address '131.103.20.167' to t
he list of known hosts.
Permission denied (publickey).
[email protected] ~
$
※ この失敗例では、作成した公開鍵をbitbucketに登録していない場合に出力されます。
成功している例
[email protected] ~/.ssh
$ ssh -T [email protected]
The authenticity of host 'bitbucket.org (131.103.20.168)' can't be established.
RSA key fingerprint is 97:8a:1b:c2:6d:14:6e:5f:3g:ec:aa:46:46:74:7h:40.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,131.103.20.168' (RSA) to the list of k
nown hosts.
logged in as daisukeota.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
[email protected] ~/.ssh
$
テストは無事完了したでしょうか?それではまた次回。