ラベル Git の投稿を表示しています。 すべての投稿を表示
ラベル Git の投稿を表示しています。 すべての投稿を表示

2010年12月17日金曜日

githubへの初回pushでsshエラー

gitをテスト環境に入れてからgithubにpushしようとしたら、少しつまずいたのでメモ。
githubの始め方はこちらのブログで分かりやすく説明されているので割愛します。
gitのインストールとgithubリポジトリ(project_hoge)の作成は事前に完了しておいて下さい。

  • githubへのssh接続に使う秘密鍵と公開鍵のペアを作成
  • ※名前は自分で指定してますが、それがすべての始まり
    ※公開鍵はgithubに追加してくださいね
    $ ssh-keygen -t rsa -C "github-hoge"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/hoge/.ssh/id_rsa): /home/hoge/.ssh/hoge_rsa
    Enter passphrase (empty for no passphrase):パスフレーズ
    Enter same passphrase again:パスフレーズ
    Your identification has been saved in /home/hoge/.ssh/hoge_rsa.
    Your public key has been saved in /home/hoge/.ssh/hoge_rsa.pub.
    The key fingerprint is:
    
  • gitの初期設定を行います
  • $ git config --global user.name "hoge"
    $ git config --global user.email "hoge@example.com"
    $ git config --global color.ui auto
    
  • git設定の確認
  • $ cat -n .gitconfig
         1     [user]
         2          name = hoge
         3          email = hoge@example.com
         4     [color]
         5          ui = auto
    
    
  • リポジトリの初期化、基本設定確認
  • $ mkdir project_hoge
    $ cd project_hoge/
    $ git init
    Initialized empty Git repository in /home/hoge/project_hoge/.git/
    $ git var GIT_COMMITTER_IDENT
    hoge  1292429310 +0900
    $ git var GIT_AUTHOR_IDENT
    hoge  1292429366 +0900
    
  • README作成、最初のコミット
  • $ touch README
    $ git add README
    $ git commit -m 'first commit'
    [master (root-commit) 92e6b51] first commit
     1 files changed, 256 insertions(+), 0 deletions(-)
     create mode 100644 README
    
  • githubをリモートリポジトリに追加
  • $ git remote add origin git@github.com:hoge/project_hoge.git
    
  • pushしようとするとエラーが発生!
  • $ git push origin master
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly
    
    SSHの鍵をデフォルトの名前にしなかった事があやしいです。
    ここらへん見るとそれらしき事が書いてます。
  • .ssh/configで使用する鍵を指定します
  • $ vi /home/hoge/.ssh/config
          1 Host                 github.com
          2 User                 git
          3 Port                 22
          4 Hostname             github.com
          5 IdentityFile         ~/.ssh/hoge_rsa
          6 TCPKeepAlive         yes
          7 IdentitiesOnly       yes
    
    $ chmod 600 .ssh/config 
    
  • 再トライをすると無事に接続が出来ます
  • $ git push origin master
    Enter passphrase for key '/home/hoge/.ssh/hoge_rsa':
    Counting objects: 3, done.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 4.57 KiB, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To git@github.com:hoge/project_hoge.git
     * [new branch]      master -> master
    


以上、メモでしたー。
今日はクラウド勉強会に参加していましたが、とても勉強になりました。
おそらく年内は最後かもですが、勉強会はとても刺激になるので来年も積極的に参加したいですね。

2010年12月15日水曜日

CentOS5.5でgit1.7.3のrpmを作成する

そうだ!ブログやってたんだ!
相変わらずの気まぐれ更新になってしまった。
勉強会とかに参加した感想をもっとキチンと書きたいなー。
ブログがある事を思い出す為にもCentOS5.5でgit1.7.3のrpmを作る手順をまとめとく。

こちらのブログが非常に手順としては参考になった。
というか手順はまんまです。

必要になりそうなパッケージをとりあえず一気にインストール

# yum -y groupinstall "Development Tools"
# yum -y groupinstall "Development Libraries"

その他以下のパッケージは必須なのでインストール

# yum -y install zlib-devel openssl-devel curl-devel expat-devel gettext xmlto gettext-devel

EPELからダウンロードしてインストールするパッケージもあります

# cd /usr/local/src/
# wget http://ftp.iij.ad.jp/pub/linux/fedora/epel/5Server/i386/asciidoc-8.1.0-1.el5.noarch.rpm
# wget ftp://ftp.iij.ad.jp/pub/linux/fedora/epel/5Server/i386/perl-Error-0.17010-1.el5.noarch.rpm
# rpm -ivh ./asciidoc-8.1.0-1.el5.noarch.rpm
# rpm -ivh ./perl-Error-0.17010-1.el5.noarch.rpm

パッケージの作成ディレクトリにソースをダウンロード

# cd /usr/src/redhat/SOURCES/
# wget http://www.kernel.org/pub/software/scm/git/git-1.7.3.tar.gz

specファイルを取り出してSPECSディレクトリに移動

# tar zxvf ./git-1.7.3.tar.gz git-1.7.3/git.spec
git-1.7.3/git.spec
# mv ./git-1.7.3/git.spec /usr/src/redhat/SPECS/

不要なディレクトリは削除します

# rm -rf ./git-1.7.3

SPECSディレクトリに移動してビルド開始

# cd /usr/src/redhat/SPECS/
# rpmbuild -bb --clean git.spec

こんな感じで作成されます

# tree /usr/src/redhat/RPMS/
/usr/src/redhat/RPMS/
|-- athlon
|-- geode
|-- i386
|   |-- git-1.7.3-1.i386.rpm
|   |-- git-all-1.7.3-1.i386.rpm
|   |-- git-arch-1.7.3-1.i386.rpm
|   |-- git-cvs-1.7.3-1.i386.rpm
|   |-- git-debuginfo-1.7.3-1.i386.rpm
|   |-- git-email-1.7.3-1.i386.rpm
|   |-- git-gui-1.7.3-1.i386.rpm
|   |-- git-svn-1.7.3-1.i386.rpm
|   |-- gitk-1.7.3-1.i386.rpm
|   |-- gitweb-1.7.3-1.i386.rpm
|   `-- perl-Git-1.7.3-1.i386.rpm
|-- i486
|-- i586
|-- i686
`-- noarch
7 directories, 11 files

あとはrpmコマンドでインストールすればOKです


すぐに消すテスト環境なのでrootユーザーで作業をしています。
各自の環境でビルドする時は一般ユーザーでビルドして下さい。