Jenkins控制器无法连接到代理

ve7v8dk2  于 12个月前  发布在  Jenkins
关注(0)|答案(1)|浏览(149)

我正在尝试Jenkins,到目前为止它很有趣。我已经能够构建一个管道,将其与我的Github配对等。现在我试图创建一个代理并与我的控制器连接,但我被拒绝连接。
我的Jenkins控制器在本地托管在一个docker容器上,我也有一个为代理运行的容器。我使用这个文档作为参考:https://www.jenkins.io/doc/book/using/using-agents/
我怀疑可能是SSH服务问题,或者我的ssh密钥被搞砸了。尽管sshd在代理上运行:

43b3773b:/home/jenkins/.ssh# ps -ef
PID   USER     TIME  COMMAND
    1 root      0:00 sshd: /usr/sbin/sshd -D -e [listener] 0 of 10-100 startups

字符串
我在authorized_keys中有jenkins控制器的pub密钥:

a81443b3773b:/home/jenkins# cat .ssh/authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCjM++SY8rWLrLYVaNgVvs+kGy3s0CSFY7TzxvF1V4hfvUs0KHX6Ej3fZStLMst1YgKV0hWiB9LhpT5ViFdjylw31K9BEGDFonpOq6PxzyfhzX0JmWw/69RgK8YGTc5+FRXrB3n4g0Z0X2WStEVtttjVuS266h4iQlsBLY8Lxho76Vj2k/x6ofuoqgQuLsshMCG+VEpXXnqxBzXQqtKoBQlIuZdmQ4iFkk2S0dKyIe9XCZzlwiKXGOeKIdJsRHJ9vf+cLk5RNjyRE0ZumWdqtXX/VdSvqAJI+dzmnNVl4Exo5S403E9OKbko5iAbOWMZkZ4NvHt6lXrlzoXMUcQWEoRQ8U66bJMkjDt8s6jbtc3K0CPzYxjBiJpoAA1DdnfDvvnHhingu6TJDA9BqQkB8EcGRqKXML1gHMGhJ2alQzxwgWdTJQzURh8FiO3m1oWZnjXaKMLhMe/egmyWxjrM48ijr0f4my8oB8gjc3ftr2Zy6FasLNePagouzXEXxWVlUc= jenkins@4cfbfa97f71d


这是我用来启动代理的命令:

docker run -d --rm --name=agent1 -p 4444:22 -e "JENKINS_AGENT_SSH_PUBKEY=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCjM++SY8rWLrLYVaNgVvs+kGy3s0CSFY7TzxvF1V4hfvUs0KHX6Ej3fZStLMst1YgKV0hWiB9LhpT5ViFdjylw31K9BEGDFonpOq6PxzyfhzX0JmWw/69RgK8YGTc5+FRXrB3n4g0Z0X2WStEVtttjVuS266h4iQlsBLY8Lxho76Vj2k/x6ofuoqgQuLsshMCG+VEpXXnqxBzXQqtKoBQlIuZdmQ4iFkk2S0dKyIe9XCZzlwiKXGOeKIdJsRHJ9vf+cLk5RNjyRE0ZumWdqtXX/VdSvqAJI+dzmnNVl4Exo5S403E9OKbko5iAbOWMZkZ4NvHt6lXrlzoXMUcQWEoRQ8U66bJMkjDt8s6jbtc3K0CPzYxjBiJpoAA1DdnfDvvnHhingu6TJDA9BqQkB8EcGRqKXML1gHMGhJ2alQzxwgWdTJQzURh8FiO3m1oWZnjXaKMLhMe/egmyWxjrM48ijr0f4my8oB8gjc3ftr2Zy6FasLNePagouzXEXxWVlUc= jenkins@4cfbfa97f71d" jenkins/ssh-agent:alpine-jdk17


pubkey是我的Jenkins控制器的。
在我的本地主机端口4444是开放的。
这是我在Jenkins代理日志中得到的错误:

SSHLauncher{host='0.0.0.0', port=4444, credentialsId='jenkins2', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=2, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.ManuallyTrustedKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[12/04/23 18:42:20] [SSH] Opening SSH connection to 0.0.0.0:4444.
Connection refused
SSH Connection failed with IOException: "Connection refused", retrying in 2 seconds. There are 10 more retries left.
Connection refused


以下是我的容器BTW:

CONTAINER ID   IMAGE                            COMMAND                  CREATED          STATUS          PORTS                                                                                      NAMES
a81443b3773b   jenkins/ssh-agent:alpine-jdk17   "setup-sshd"             48 minutes ago   Up 41 minutes   0.0.0.0:4444->22/tcp, :::4444->22/tcp                                                      agent1
4cfbfa97f71d   jenkins/jenkins:lts              "/usr/bin/tini -- /u…"   5 days ago       Up 55 minutes   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:50000->50000/tcp, :::50000->50000/tcp   brave_pascal


任何帮助都非常感谢:)

nbysray5

nbysray51#

能够让它工作。不得不使用代理容器的IP和端口22而不是4444。

相关问题