DEVOPS技术实践_16:使用Centos容器作为salve的报错offline的问题

上一篇创建了一个centos的容器,而且已经安装了openssh

[root@node6 ~]# docker ps -a

f2320c5d3c54        centos                "/bin/bash"              40 minutes ago      Exited (0) 12 seconds ago                       compassionate_elbakyan

[root@node6 ~]# docker images

centos_jenkins                                latest              deca1dcb74be        3 minutes ago       703MB

1. 配置作为jenkins 的slave

2. 点击构建

3. 构建结果

处于offline状态

尝试连接

SSHLauncher{host='192.168.132.136', port=32797, credentialsId='acd6a413-a34d-443d-9cd2-1f751fa1c488', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=210, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[10/27/19 11:32:49] [SSH] Opening SSH connection to 192.168.132.136:32797.
[10/27/19 11:32:49] [SSH] WARNING: SSH Host Keys are not being verified. Man-in-the-middle attacks may be possible against this connection.
ERROR: Unexpected error while trying to authenticate as jenkins with credential=acd6a413-a34d-443d-9cd2-1f751fa1c488
java.io.IOException: Password authentication failed.
    at com.trilead.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:357)
    at com.trilead.ssh2.Connection.authenticateWithPassword(Connection.java:340)
    at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPasswordAuthenticator.doAuthenticate(TrileadSSHPasswordAuthenticator.java:113)
    at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.authenticate(SSHAuthenticator.java:436)
    at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.authenticate(SSHAuthenticator.java:473)
    at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:855)
    at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:419)
    at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:406)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: The connection is closed.
    at com.trilead.ssh2.auth.AuthenticationManager.deQueue(AuthenticationManager.java:72)
    at com.trilead.ssh2.auth.AuthenticationManager.getNextMessage(AuthenticationManager.java:100)
    at com.trilead.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:332)
    ... 11 more
Caused by: java.io.IOException: Cannot read full block, EOF reached.
    at com.trilead.ssh2.crypto.cipher.CipherInputStream.getBlock(CipherInputStream.java:81)
    at com.trilead.ssh2.crypto.cipher.CipherInputStream.read(CipherInputStream.java:108)
    at com.trilead.ssh2.transport.TransportConnection.receiveMessage(TransportConnection.java:232)
    at com.trilead.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:706)
    at com.trilead.ssh2.transport.TransportManager$1.run(TransportManager.java:502)
    ... 1 more
[10/27/19 11:32:49] [SSH] Authentication failed.
Authentication failed.
[10/27/19 11:32:49] Launch failed - cleaning up connection
[10/27/19 11:32:49] [SSH] Connection closed.

4. 进入容器修改ssh配置文件

[root@node6 ~]# docker exec -it f2320c5d3c54 /bin/bash

[root@f2320c5d3c54 /]# vi /etc/ssh/sshd_config

添加修改下面两行

UsePAM no    
UsePrivilegeSeparation no

[root@f2320c5d3c54 /]# exit

5. 提交到镜像

[root@node6 ~]# docker commit f2320c5d3c54 centos_jenkins_2

sha256:796d156227e69f272f8b524516ec666eef3715e467d6756bf20333b35f0fe89c

6.修改配置的镜像,再次构建

生成一个容器

7. 查看容器

[root@node6 ~]# docker ps -a

48d75354bd9b        centos_jenkins_2      "/usr/sbin/sshd -D -…"   About a minute ago   Up About a minute          0.0.0.0:32798->22/tcp   optimistic_grothendieck

构建完成之后再次查看容器

[root@node6 ~]# docker ps -a

容器已经删除

centos作为slave镜像配置完成

原文地址:https://www.cnblogs.com/zyxnhr/p/11809180.html