ルニラボ

lni_T の長文置き場

CentOS6.2でBitBucketのリモートリポジトリを使用する

CentOSからBitBucketのリモートリポジトリにfetchしようとして、ちょっとハマった所をメモ

基本手順

下記のURL通りに進めればできる 公式手順(和訳) http://confluence.atlassian.jp/pages/viewpage.action?pageId=35095517

ハマった所1 アクセス権がない - Permission denied (publickey).

現象

そもそも認証できない

$ ssh bitbucket.org 

を実行して上記のエラーが出る

解決方法

CentOSでは起動後にssh-addしないと鍵を使ってくれない

$ ssh-agent
$ ssh-add [秘密鍵ファイル指定]

すると鍵を使ってくれる

ssh接続後以下のメッセージが返ってくれば認証OK

logged in as ******.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
Connection to bitbucket.org closed.

ハマった所2 - gitリポジトリSSH認証できない

現象

いざgit fetchやgit pushしようとした時にパスワードを求められる

解決方法

gitの設定をHTTPS -> SSHに変更する [リポジトリ]/.git/config にあるリポジトリのconfigを確認し url = https://username@bitbucket.org/username/reponame.git のようにパスがHTTPSになっていた場合 url = git@bitbucket.org:username/hellobitbucket.git とSSHアクセス用のパスに変更する

これで認証可能

その他

より初心者向けの解説 http://morizyun.github.io/blog/ssh-key-bitbucket-github/ http://sseze.hatenablog.com/entry/2013/01/03/155711