【发布时间】:2017-01-18 19:29:47
【问题描述】:
我正在尝试调试一个似乎由于 SSH 权限问题而失败的Jenkins Plugin。基本上,该插件允许我从主机通过 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
【问题讨论】:
-
您是否在 prod 服务器上注册了您的公共 ssh 密钥?
-
感谢您的回复!我刚刚检查了密钥,并且我在从机的 authorized_keys 文件中拥有来自主机的公钥。我似乎能够毫无问题地通过 ssh 进入从机,但正是
ssh -p 43689 localhost在生产设置上给我带来了权限被拒绝错误的问题:/ 我尝试将主机上的 id_rsa.pub 添加到同一台机器上的 authorized_keys机器,但它仍然没有真正工作...... -
'权限被拒绝'或'连接被拒绝'?你确定有人在监听 43689 端口吗?
-
绝对权限被拒绝!我刚刚检查了活动端口,该端口确实在监听。
-
谁在监听这个端口?哪个用户拥有监听此端口的进程?