パスワードを忘れた? アカウント作成
402391 journal

yk700101の日記: OpenMicroServer - etch - cvs (ssh, WinCvs)

日記 by yk700101
○概要
    OpenMicroServer + Debian GNU/Linux 4.0(etch)に
    cvs (および ssh)をインストールしたときのメモ。
    (クライアントからの動作確認は
            Windows XP にインストールした WinCvs を使用。)

○前提
    1. OpenMicroServer + Debian GNU/Linux 4.0(etch) に
          Samba を インストールした後の環境を使用。

○目的
  1. 別の外付け HD に sarge と同様の環境を etch で構築する。

○cvs のインストール
    apt-get install cvs

    #確認
    cvs -v

○ssh のインストール
    apt-get install ssh

    #確認
    ps -C sshd

    #設定の確認
    cat /etc/ssh/sshd_config

    # root でログオンできるようになっていたり、
    # パスワード認証が有効になっていたりすると、
    # あまり良くないらしい。
    # さらに、 ssh でログオンできるユーザを特定(指定)したいものだが、
    # 今回は気にしない。

○cvs 用ユーザの追加
    export testusername=cvstest

    #テストユーザ追加
    # (データディレクトリ(/srv/data1)にアクセスできるようにするために、
    # とりあえず sambaadmin グループに所属させる。)
    useradd -G sambaadmin -m ${testusername}
    passwd ${testusername}

○リポジトリ作成(テスト用)
    su - ${testusername}

    export repository=/srv/data1/CVSRepository/test
    export projectname=testproject
    export testfilename=testfile.txt

    #リポジトリ作成
    cvs -d ${repository} init

○インポート
    export tempdir=temp

    #一時ディレクトリを作成して、
    # ファイルを格納し、リポジトリに登録する。

    mkdir ${tempdir}
    cd ${tempdir}
    echo '1' > ${testfilename}

    cvs -d ${repository} \
        import \
            -m 'for test' \
                ${projectname} 'test-vendor' 'test-release'

    #一時ディレクトリの削除
    cd ..
    rm -r ${tempdir}

○チェックアウト
    cvs -d ${repository} \
        checkout ${projectname}

○ファイルの更新
    cd ${projectname}

    #変更前の状態の確認
    cvs log
    cvs status
    cvs update
    cat ${testfilename}

    #変更
    echo '2' >> ${testfilename}

    #変更後の状態の確認
    cvs log
    cvs status
    cvs update
    cat ${testfilename}

    #変更点の確認
    cvs diff
    cvs diff -c
    cvs diff --side-by-side

    #変更点のコミット
    cvs commit -m 'test change'

    #コミットの確認
    cvs log
    cvs status
    cvs update

○ファイルの追加
    export testfilename2=testfile2.txt
    echo 'a' > ${testfilename2}

    #追加前の状態の確認
    cvs log ${testfilename2}
    cvs status ${testfilename2}
    cvs update

    #追加
    cvs add ${testfilename2}

    #コミット前の状態の確認
    cvs log ${testfilename2}
    cvs status ${testfilename2}
    cvs update

    #コミット
    cvs commit -m 'test add' ${testfilename2}

    #コミット後の状態の確認
    cvs log ${testfilename2}
    cvs status ${testfilename2}
    cvs update

○ファイルの削除
    #(注:削除取り消しは、cvs add で行う。)
    cvs remove -f ${testfilename2}

    #コミット前の状態の確認
    cvs log ${testfilename2}
    cvs status ${testfilename2}
    cvs update

    #コミット
    cvs commit -m 'test remove' ${testfilename2}

    #コミット後の状態の確認
    cvs log ${testfilename2}
    cvs status ${testfilename2}
    cvs update

○サンドボックスの削除
    cd

    cvs -d ${repository} release -d ${projectname}

        Are you sure you want to release (and delete) directory
            → y

○ssh 経由での操作
    export repository_ext=:ext:${testusername}@OMS${repository}

    #--------------------
    # 公開鍵認証の準備
    #--------------------
    #鍵ペアの作成
    ssh-keygen

        Enter file in which to save the key (/home/cvstest/.ssh/id_rsa):
            → (Return)

        Enter passphrase (empty for no passphrase):
            → パスフレーズを入力する。

        Enter same passphrase again:
            → 同じパスフレーズを入力する。

    #作成した公開鍵のファイルを元に
    # 認証済み公開キーを格納するファイルを作成する。
    cp .ssh/id_rsa.pub .ssh/authorized_keys

    #ssh を通じた操作を
    # 初回のパスフレーズのみの入力で済ませるために、
    # ssh-agent を起動する。
    eval `ssh-agent`

    #秘密鍵を読み込む
    ssh-add

        Enter passphrase for /home/cvstest/.ssh/id_rsa:
            → パスフレーズを入力する。

    #--------------------
    # ssh 経由での操作
    #--------------------
    #チェックアウト
    cvs -d ${repository_ext} \
        checkout ${projectname}

        Are you sure you want to continue connecting (yes/no)?
            → yes

    #サンドボックスの削除
    cvs -d ${repository_ext} release -d ${projectname}

        Are you sure you want to release (and delete) directory
            → y

○WinCvs(2.0.2.4) から ssh 経由での操作
    (注:
            試用中。
            ASCII なら大丈夫だと思われるが、
            日本語が使えるものかどうか良く分からない。
      )

    以下のサイトから WinCvs をダウンロード。

        ・CvsGui
            http://www.wincvs.org/index.html

    リポジトリに

        :ext:cvstest@OMS:/srv/data1/CVSRepository/test

    を指定してチェックアウトを実行すると、
    以下のエラーメッセージが出力される。

        cvs diff: warning: unrecognized response `'ssh' は、内部コマンドまたは外部コマンド、
        ' from cvs server
        cvs diff: warning: unrecognized response `操作可能なプログラムまたはバッチ ファイルとして認識されていません。
        ' from cvs server
        cvs [diff aborted]: end of file from server (consult above messages if any)

    Windows 用の ssh 関連コマンドを得るために
    以下のサイトから、

        ・PuTTY: a free telnet/ssh client
            http://www.chiark.greenend.org.uk/~sgtatham/putty/

    以下のファイル(Version 0.60)をダウンロードし、
        C:\yk_prog\Putty
    に格納する。

        plink.exe
            → ssh コマンド本体。

        pageant.exe
            → 秘密鍵を使用する際のパスフレーズの入力を
                    最初の1回のみにするためのもの。

        puttygen.exe
            → putty のツールで使用するフォーマットの
                    秘密鍵と公開鍵を作成するためのもの。

    ssh コマンドの場所を設定する画面が見つからなかったので、
    環境変数
        CVS_RSH
    に plink.exe のフルパス
        C:\yk_prog\Putty\plink.exe
    を指定して起動する。
    (起動している WinCvs を終了し、以下のコマンドで WinCvs を起動する。

        cmd /C set CVS_RSH=C:\yk_prog\Putty\plink.exe & cd /D "C:\yk_prog\Gnu\WinCvs 2.0" & start wincvs.exe

    再度 チェックアウトを実行すると、
    以下のエラーメッセージが出力され続ける。

        cvs update: warning: unrecognized response `Password:
        ' from cvs server

    パスワードを入力しなくても
    ssh を実行できるようにする必要があるようなので、
    まず、パスワード認証の代わりに公開鍵認証で認証を行うようにする。

    puttygen.exe を実行して、秘密鍵と公開鍵を作成(Ganarate)する。
    (マウスをぐるぐる回すと、早く処理が終わる模様。)

    作成が完了したら、パスフレーズを入力し、
    秘密鍵を cvstest.ppk として保存(Save private key)する。

    画面上に、OpenSSH 用のフォーマットの公開鍵(鍵の値は同じ)
    が表示されているので、
    これをすべてコピーし、

    cvstest@OMS の
        ~/.ssh/authorized_keys
    に貼り付ける。
    (最終行に追加する。)

    pageant.exe を cvstest.ppk を引数に指定して実行する。
    (以下のコマンドを実行する。)

        C:\yk_prog\Putty\pageant.exe C:\yk_prog\Putty\cvstest.ppk

        (パスフレーズを入力する。)

    plink.exe で OMS に接続する。
    (新しい接続先と認識されて回答を求めるメッセージが表示されてしまい、
            Wincvs でエラーが発生してしまうため、
            先に、
            Windows のレジストリ(HKEY_USERS\・・・\Software\SimonTatham\PuTTY\SshHostKeys)に
            保管されている Host Key を更新しておく必要がある。)
    (以下のコマンドを実行する。)

        cmd /K C:\yk_prog\Putty\plink.exe cvstest@OMS

        (以下のメッセージが表示される。)
                WARNING - POTENTIAL SECURITY BREACH!
                The server's host key does not match the one PuTTY has
                cached in the registry. This means that either the
                server administrator has changed the host key, or you
                have actually connected to another computer pretending
                to be the server.
                The new rsa2 key fingerprint is:

                (中略)

                If you were expecting this change and trust the new key,
                enter "y" to update PuTTY's cache and continue connecting.
                If you want to carry on connecting but without updating
                the cache, enter "n".
                If you want to abandon the connection completely, press
                Return to cancel. Pressing Return is the ONLY guaranteed
                safe choice.
                Update cached key? (y/n, Return cancels connection)

                    → y

    再度 チェックアウトを実行すると、処理が成功する。

    ・検討中の事項
        日本語を含むテキストファイル(UTF-8, SJIS, EUC)はバイナリファイルと
        して取り扱われる?
        (警告がでる。)

        でも、テキストファイルとして格納して、
        サーバ側で
            cvs annotate
        を実行すると行ごとの変更が認識されているような気がする。

        日本語のファイル名は、試していない。

        日本語のコメントは SJIS で記録される模様。

    ・参考
        ・PuTTYを使ったCVS利用法
            http://rumble-jp.osdn.jp/putty-howto/putty-doc.html

○テストの後始末

    # cvstest から root に戻る。
    exit

    #ユーザの削除
    userdel -r cvstest

    #リポジトリの削除
    rm -r /srv/data1/CVSRepository/test/

○参考
    ・ローカルのドキュメント
        zcat /usr/share/doc/cvs/README.Debian.gz
        zcat /usr/share/doc/cvs/contrib/README.gz
        info CVS

○更新履歴
        2007/11/14 作成

以上。
typodupeerror

UNIXはただ死んだだけでなく、本当にひどい臭いを放ち始めている -- あるソフトウェアエンジニア

読み込み中...