私はドッカーコンテナ内のJenkinsを実行しています。ドッカーのJenkinsスレーブがSSHキーを拒否しています
[11/18/16 20:46:21] [SSH] Opening SSH connection to 192.168.99.100:32826.
ERROR: Server rejected the 1 private key(s) for Jenkins (credentialId:528bbe19-eb26-4c9f-bae3-82cd1247d50a/method:publickey)
[11/18/16 20:46:22] [SSH] Authentication failed.
hudson.AbortException: Authentication failed.
at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1217)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:711)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:706)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[11/18/16 20:46:22] Launch failed - cleaning up connection
[11/18/16 20:46:22] [SSH] Connection closed.
私はsshのキーはそれが期待されている場所であることを確認するために家/ジェンキンス/ .sshディレクトリに取得することができていますdocker exec -i -t slave_name /bin/bash
コマンドを使用する:他のドッキングウィンドウコンテナ内のノードを分社すると、私はメッセージを受け取りますさあ。
私のconfigureページ上のクラウドheadnig下でテスト接続は
バージョン= 1.12.3、APIのバージョン= 1.24
を返します。
私はOSX Sierraを実行しており、RIOT Games Jenkins-Dockerチュートリアルhttp://engineering.riotgames.com/news/building-jenkins-inside-ephemeral-docker-containerに従っています。
ジェンキンスマスタードッカーファイル:
FROM debian:jessie
# Create the jenkins user
RUN useradd -d "/var/jenkins_home" -u 1000 -m -s /bin/bash jenkins
# Create the folders and volume mount points
RUN mkdir -p /var/log/jenkins
RUN chown -R jenkins:jenkins /var/log/jenkins
VOLUME ["/var/log/jenkins", "/var/jenkins_home"]
USER jenkins
CMD ["echo", "Data container for Jenkins"]
ジェンキンススレーブDockerfile
FROM centos:7
# Install Essentials
RUN yum update -y && yum clean all
# Install Packages
RUN yum install -y git \
&& yum install -y wget \
&& yum install -y openssh-server \
&& yum install -y java-1.8.0-openjdk \
&& yum install -y sudo \
&& yum clean all
# gen dummy keys, centos doesn't autogen them.
RUN /usr/bin/ssh-keygen -A
# Set SSH Configuration to allow remote logins without /proc write access
RUN sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional \
pam_loginuid.so/' /etc/pam.d/sshd
# Create Jenkins User
RUN useradd jenkins -m -s /bin/bash
# Add public key for Jenkins login
RUN mkdir /home/jenkins/.ssh
COPY /files/authorized_keys /home/jenkins/.ssh/authorized_keys
RUN chown -R jenkins /home/jenkins
RUN chgrp -R jenkins /home/jenkins
RUN chmod 600 /home/jenkins/.ssh/authorized_keys
RUN chmod 700 /home/jenkins/.ssh
# Add the jenkins user to sudoers
RUN echo "jenkins ALL=(ALL) ALL" >> etc/sudoers
# Set Name Servers to avoid Docker containers struggling to route or resolve DNS names.
COPY /files/resolv.conf /etc/resolv.conf
# Expose SSH port and run SSHD
EXPOSE 22
CMD ["/usr/sbin/sshd","-D"]
私は別の個人が同じ場所で立ち往生しているLinuxマシン上で同じチュートリアルをやって取り組んできました。どんな助けもありがとう。
私は 'RUN useradd jenkins -m -s/bin/bash'を使ってJenkinsユーザを作成しています。このコマンドの後に 'ssh-keyscan -H 192.168.99.100 >>/home/jenkins/.ssh/known_hosts'と' RUN ssh-keyscan -H 192.168.99.100 >> /home/jenkins/.ssh/を追加しようとしました。 known_hosts'です。どちらもビルドに失敗します。コマンド/ bin/sh -c ssh-keyscan -H 192.168.99.100 >> /home/jenkins/.ssh/known_hostsが「0以外のコードを返しました:1」と実行されていないバージョン「不明命令:SSHキースキャン。よく知られているものが見つからない場合はお詫び申し上げます。 – CosetteN
エラーが発生しますか(jenkinsとしてコマンドを実行するか、known_hostsを追加するのが最善です)。そして、あなたは奴隷から習得していくことができますか? Yesの場合、known_hostsにホストを追加するように要求するべきではありません – Rik
実際に 'RUN ssh-keyscan ... 'を使うべきですが、実際にはURLをスキャンします。したがって、マスターがオンラインでない場合、それは動作しません。あなたができることは、マスターとスレーブの実行後、スレーブからマスターへのssh、そしてknown_hostsファイルをコピーしてdockerfileに入れます。 – Rik