何が悪かったのか
私はubuntu12.10サーバーを持っています。
JenkinsとNginxを同じサーバーにインストールしました。
Nginxがファイルをサーバーすることになっている/var/ virtualには、www-data:www-dataの権限設定があります
ユーザーjenkins
はJenkinsソフトウェアを実行しています。
これはphingbuild.xmlで書かれた私のターゲットです
<target name="gitclone">
<echo msg="gitclone ${environment.branch} branch code to ${environment} environment" />
<exec command="ssh -A ${host-used} 'git clone -b ${repository-uri} ${environment.branch} ${environment.sitedir}${build.time}'"
outputProperty="result" escape="false"/>
<echo msg="${result}" />
<echo msg="update all the submodules after gitclone" />
<exec dir="${environment.sitedir}${build.time}" command="ssh -A ${host-used} 'git submodule update --init --recursive'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>
これは、jenkinsからのコンソール出力です。
[echo] gitclone master branch code to production environment
[echo] Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
[echo] update all the submodules after gitclone
Execution of target "gitclone" failed for the following reason: /var/lib/jenkins/jobs/abc-master/workspace/build.xml:116:48: '/var/virtual/abc.com/2013_01_11_07_45_35' is not a valid directory
私が試したこと
グーグルで検索したところ、sshエージェントの転送に関するこのgithubの記事を見ました。
これが私が試したものです。
私はjenkinsとしてサーバーにSSH接続します。
それから私はタイプしました
ssh -T www-data@xxx.xx.xxx.xx
www-data@xxx.xx.xxx.xxパスワードの入力を求められ、それを入力しました。今後のxxx.xx.xxx.xxは、同じサーバーのIPアドレスを参照することに注意してください。
www-dataとして正常にログインしたので、www-data@xxx.xx.xxx.xxを終了しました。これで、ユーザーとしてサーバーに戻りjenkins
ます。
今試してみます
echo "$SSH_AUTH_SOCK"
何も得られませんでした。
/var/lib/jenkins/.ssh/configにアクセスして、次のように入力しました。
Host xxx.xx.xxx.xx
ForwardAgent yes
IdentityFile /var/lib/jenkins/.ssh/id_rsa
StrictHostkeyChecking no
もう一度Jenkins
ジョブを作成します。失敗。
次に、www-data〜/ .ssh / authorized_keysファイル内にauthorized_keysを設定して、jenkins@xxx.xx.xxx.xxからwww-data@xxx.xx.xxx.xxに移動するたびに設定する必要があると思いました。パスワードの入力を求められません。
だからjenkins
、私はタイプしました
cat ~/.ssh/id_rsa.pub | ssh www-data@xxx.xx.xxx.xx 'cat >> .ssh/authorized_keys'
それから私はタイプしました
ssh -T www-data@xxx.xx.xxx.xx
www-data@xxx.xx.xxx.xxパスワードの入力を求められ、それを入力しました。
今回はパスワードの入力を求められずにwww-dataとして正常にログインしたので、www-data @xxx.xx.xxx.xxを終了しました。これで、ユーザーとしてサーバーに戻りjenkins
ます。
もう一度Jenkins
ジョブを作成します。失敗。
としてjenkins
、私は入力しました
echo "$SSH_AUTH_SOCK"
何も見られなかった。
試してみました
ssh-add -L
了解しました
Could not open a connection to your authentication agent.
編集/etc/ssh/sshd_config
および追加
AllowAgentForwarding yes
チェック済み/etc/ssh/ssh_config
。設定なしForwardAgent no
。
もう一度Jenkins
ジョブを作成します。失敗。