gitolite でポート指定する場合の git clone の仕方

なんかすごくハマった

1. リモートから鍵を取ってくる

scp user@remote.example.com:10022/.ssh/id_rsa ~/.ssh/id_rsa.user

2. 以下のように.ssh/configを設定

.ssh/config

Host examplehost
    Hostname remote.example.com
    User gitolite
    Port 10022
    IdentityFile ~/.ssh/id_rsa.user

3. git clone コマンドを打つ

% git clone ssh://examplehost/testing

ドキュメント的には以下でいけるらしい

ssh のポートが違う場合、2つ目で。

  • @:reponame.git
  • ssh://@:/reponame.git

確認用コマンド

% ssh -p 2222 gitolite@remote.example.com info
hello user, this is gitolite v2.2-12-g8067c8e running on git 1.7.6.4
the gitolite config gives you the following access:
    @R_ @W_     testing
     R   W      rhoge_repository

リモートの gitolite-admin 以下を弄りたい

  • /gitolite-admin/conf/

server /home/gitolite/.ssh/authorized_keys にユーザのkeyを追加する

以下は、git clone できるが、git pushする時に失敗する。フルパスでレポジトリを指定すると、pushに失敗するのは仕様らしい。

git clone ssh://remotehost/home/gitolite/repositories/gitolite-admin


git push時のエラー内容

% git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 308 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: ENV GL_RC not set
remote: BEGIN failed--compilation aborted at hooks/update line 20.
remote: error: hook declined to update refs/heads/master
To ssh://remotehost/home/gitolite/repositories/gitolite-admin
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'ssh://remotehost/home/gitolite/repositories/gitolite-admin'
% git remote -v

参考用ドキュメント

公式なマニュアル: github のソース
  • sitaramc.github.com/gitolite/

http://sitaramc.github.com/gitolite/

  • doc/ssh-troubleshooting.mkd at pu from sitaramc/gitolite - GitHub

https://github.com/sitaramc/gitolite/blob/pu/doc/ssh-troubleshooting.mkd#_bypassing_gitolite_without_intending_to

  • Gitolite Troubleshooting Checklist – part 4 | Geek Gumbo

http://www.geekgumbo.com/2011/10/24/gitolite-troubleshooting-checklist-part-4/

  • いまさら さくらVPS(CentOS5) を設定をしてみた。Git, Gitolite編 | st.Prestage

http://st-prestage.jp/vps/sakura-setting-git/

正しいかわからないが

Edit your .git/config file and replace the line with :

url = git_user_name@http://server_ip:repo_name.git

to the following:

url = ssh://git_user_name@external_ip:non_standard_ssh_port/repo_name.git