Windows で plink.exe を利用して Bitbucket.org から clone してみる。
どなたかが Windows plink.exe を利用して Bitbucket.org から Mercurial のリポジトリを clone できねと言っていたので記事作成しました。
0. 前提条件
1. 秘密鍵と公開鍵の作成
ページの「SSH用の鍵を作成する(*nix環境で作成した秘密鍵を使う場合は後述) 」 を参考にして、秘密鍵(と公開鍵)を作成します。鍵の名前は任意ですが、Bitbucket.org 用であることと、どちらが秘密鍵でどちらが公開鍵かはわかるようにしてください。
作成した秘密鍵へのパスを \path\to\privatekey.ppk とします。
2. Bitbucket.org にログインして、公開鍵の登録
1. 1 ユーザ名から 2 Account をクリックします。
2. 表示された画面の 3 SSH Keys をクリックします。
3. 画像の画面が表示されるので、4 ラベル名と 5 公開鍵の中身のテキストを記載して Add key をクリックします。
3. plink.exe での接続確認
コマンドプロンプトを立ち上げて、次のコマンドを入力します。
"\path\to\plink.exe" -ssh -C -i "\path\to\privatekey.ppk" hg@bitbucket.org
以下は入力例です。途中で Store key in cache? と聞かれているのは接続先のフィンガープリントを登録するか否かの質問で、今回の接続先はそれなりに信頼できると思うので y を入力してください。フィンガープリントについて、詳しくは Turbolinux 11 Server: ユーザーガイド 21.4.2. ホスト認証と暗号化通信の手続き のページを参照してください。
正しく接続できたら、 conq: logged in as (ユーザ名). のような文言が返ってきます。
>"\path\to\plink.exe" -ssh -C -i "\path\to\privatekey.ppk" hg@bitbucket.org The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server's rsa2 key fingerprint is: ssh-rsa 2048 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40 If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n) y Using username "hg". Server refused to allocate pty conq: logged in as (ユーザ名). You can use git or hg to connect to Bitbucket. Shell access is disabled.