gpt4 book ai didi

linux - SSH - 帮助理解代理命令

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:25:21 26 4
gpt4 key购买 nike

我正在尝试调试 Jenkins Plugin这似乎是由于 SSH 权限问题而失败。基本上,该插件允许我从主计算机通过 SSH 连接到从计算机上构建的特定 Jenkins,但由于某种原因,它在我尝试使用它的系统上失败了。

执行时,插件告诉我可以使用类似于以下命令的命令从主计算机通过 SSH 进入从属构建:

ssh.config

Host=*.localhost
Port=43689
ProxyCommand=ssh -p 43689 localhost diagnose-tunnel -suffix .localhost %h

命令:

ssh -F ssh.config Test.localhost

这适用于我设置的测试系统(使用两台机器),但在生产环境中失败并出现错误Permission denied (publickey)

虽然我当然愿意自己调试权限问题,但我真的很困惑这个 ssh 命令是如何工作的:/它到底想做什么?我研究了这个问题,但我仍然对它如何与代理命令一起工作感到困惑。

我想象它连接到本地主机(jenkins 主机)中的某个自定义端口,但这如何让我通过 ssh 进入从机?为了便于阅读,可以将此命令重写为一行吗?什么可能导致权限被拒绝错误?

感谢您的帮助!我想这可能是一个非常简单的问题,但我是 SSH 的新手,并且仍在努力理解它:)

更新

ssh -vF test_ssh <job>.<host> 的输出, 按照要求! ^^(为了便于阅读,作业和主机被标签替换)

OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data test_ssh
debug1: Applying options for *.<host>
debug1: Executing proxy command: exec ssh -p 44078 <host> diagnose-tunnel -suffix .<host> <job>
debug1: permanently_drop_suid: 497
debug1: identity file /var/lib/jenkins/.ssh/identity type -1
debug1: identity file /var/lib/jenkins/.ssh/identity-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_rsa type 1
debug1: identity file /var/lib/jenkins/.ssh/id_rsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_dsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_dsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ecdsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ecdsa-cert type -1
Permission denied (publickey).
ssh_exchange_identification: Connection closed by remote host

最佳答案

你的 ssh.config 还应该包含类似的东西

User USERNAME
PubKeyAuthentication yes
IdentityFile /path/to/key

其中 USERNAME 是允许连接到您的产品服务器的实际用户,/path/to/key 是他们的私钥在此之前你应该已经完成​​了

ssh-copy-id -i/path/to/key.pub SERVER

SERVER 是您的产品主机

关于linux - SSH - 帮助理解代理命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36081742/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com