2011年8月22日月曜日

CentOS5.6にGit導入→公開(未完成)

鍵生成にはPuTTYgenを推奨

1.インストール
$ wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
$ sudo rpm -ivh epel-release-5-4.noarch.rpm
$ sudo yum -y install git gitosis
$ ssh-keygen -t rsa

2.鍵登録
・PuTTYgenで鍵を生成(※OpenSSH形式じゃないと上手くいかないっぽい点に留意)
$ mkdir /root/.ssh
$ vi /root/.ssh/id_rsa.pub
・「OpenSSHのauthorized_keysファイルにペーストするための公開鍵」の部分をコピーして/root/.ssh/id_rsa.pubに貼りつけ&保存
$ vi /root/.ssh/id_rsa
・PuTTYgen>変換>OpenSSH形式へエクスポートを実行し出てきたファイルの中身を/root/.ssh/id_rsaに貼りつけ&保存
$ sudo -H -u gitosis gitosis-init < /root/.ssh/id_rsa.pub

3.管理ファイルのダウンロード
$ passwd gitosis
Changing password for user gitosis.
New UNIX password:[任意のパスワード]
Retype new UNIX password:[任意のパスワード]

$ mkdir /root/work
$ cd /root/work

$ git clone ssh://gitosis@localhost/gitosis-admin.git
Cloning into gitosis-admin...
The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is bd:24:...:9c:83.
Are you sure you want to continue connecting (yes/no)? [yes]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/root/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /root/.ssh/id_rsa
Enter passphrase for key '/root/.ssh/id_rsa':[空Enter]
gitosis@localhost's password:[↑で設定した任意のパスワード]
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 5 (delta 0)
Receiving objects: 100% (5/5), done.

4.管理ファイルの設定
$ cd gitosis-admin
$ vi gitosis.conf

#最下行に以下追加
[group test]
writable = test-dev
members = testuser
#ココマデ

$ vi keydir/testuser.pub
・追加したいユーザーの「OpenSSHのauthorized_keysファイルにペーストするための公開鍵」を貼付け
$ cd keydir
$ git add testuser.pub
$ cd ../
$ git commit -am "Comment" -a
$ git push
Enter passphrase for key '/root/.ssh/id_rsa':[空Enter]
gitosis@localhost's password:[↑で設定した任意のパスワード]

・新規リポ追加
$ cd ../
$ mkdri test-dev
$ cd test-dev
$ git init
$ touch dummy
$ git add dummy
$ git commit -am "Comment"
$ git remote add origin gitosis@localhost:test-dev.git
$ git push origin master:refs/heads/master