Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 我能';无法使用公钥和私钥从Jenkins节点SSH到远程服务器_Linux_Jenkins_Ssh_Jenkins Pipeline - Fatal编程技术网

Linux 我能';无法使用公钥和私钥从Jenkins节点SSH到远程服务器

Linux 我能';无法使用公钥和私钥从Jenkins节点SSH到远程服务器,linux,jenkins,ssh,jenkins-pipeline,Linux,Jenkins,Ssh,Jenkins Pipeline,我正在尝试从Jenkins节点将ssh远程连接到远程linux机器。我在Jenkins节点中创建了公钥和私钥,并将公钥复制到远程机器中的授权密钥。但我不能远程进入远程机器。请检查下面的日志 /home/us-jenkins/jenkins/workspace/engineering/dex/college-dex@tmp/durable-9222db0d/script.sh: line 8: warning: here-document at line 2 delimited by end-of

我正在尝试从Jenkins节点将ssh远程连接到远程linux机器。我在Jenkins节点中创建了公钥和私钥,并将公钥复制到远程机器中的授权密钥。但我不能远程进入远程机器。请检查下面的日志

/home/us-jenkins/jenkins/workspace/engineering/dex/college-dex@tmp/durable-9222db0d/script.sh: line 8: warning: here-document at line 2 delimited by end-of-file (wanted `EOF')
+ ssh -vvv ****@208.53.147.236
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 62: Applying options for *
Pseudo-terminal will not be allocated because stdin is not a terminal.
debug1: Executing proxy command: exec /usr/bin/sss_ssh_knownhostsproxy -p 22 208.53.147.236
debug1: permanently_drop_suid: 1990977432
debug1: identity file /home/us-jenkins/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/us-jenkins/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/us-jenkins/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/us-jenkins/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/us-jenkins/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/us-jenkins/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/us-jenkins/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/us-jenkins/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: Connection closed by remote host
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 255
Finished: FAILURE
如果需要任何细节,请告诉我。我们将非常感谢您提供的任何帮助。

请确保您已经:

  • 在jenkins中将私钥注册为SSH凭据
  • 使用无密码短语的私钥,或使用
  • 在管道步骤中同时使用这两个元素
:

stage('Deploy'){
台阶{
sshagent(凭据:['use-the-id-from-credential-generated-by-jenkins']{
As,这意味着它的执行用户必须有一个
ssh.config
(比如
/etc/ssh/ssh\u config
)来指示任何ssh调用通过该代理


如果所述代理失败,这将解释错误消息。

问题可以解决。问题是我们的jenkins服务器位于受限网络中,因此SSH无法工作。我们删除了防火墙上的限制,问题得到了解决。

Hi@VonC I在jenkins中将私钥注册为SSH凭据,并使用sshagent(凭据:['use-the-id-from-credential-generated-by-jenkins']在Jenkins Pipeline阶段。但我仍然收到相同的错误。@RaghuRam您的私钥受密码短语保护吗?为了确保密钥正常工作,我将私钥复制到我的Mac计算机,并尝试SSH到远程服务器,该操作成功。但当从Jenkins执行SSH时,我收到了此错误。Hi@VonC my private密钥不受密码短语保护。@RaghuRam“正在执行代理命令”:我起初没有看到这一部分。这可以解释用户会话和Jenkins会话之间的区别。
ssh\u exchange\u标识:远程主机关闭的连接
这一行表示与ssh服务器的连接在打开后立即关闭。“正在执行代理命令”第行表示您正试图通过另一个到208.53.147.236的ssh连接代理连接。问题可能是到208.53.147.236的连接失败。在尝试通过它代理连接之前,请确保该连接正常。@Kenster如果我需要检查Jenkins节点或远程服务中的任何文件,请您详细解释一下呃。@Kenster我在~/.ssh文件夹中找不到任何ssh\u config文件。从中执行此代理命令。请尝试在ssh\u config
\ProxyCommand/usr/bin/sss\u ssh\u nownhostsproxy-p%p%h
@Kenster我找不到ssh\u配置。请在/usr/bin-rwxr-xr-x.1 root 774中找到以下详细信息568 Jun 26 2019 ssh-rwxr-xr-x.1根根目录360920 Jun 26 2019 ssh-add-rwxr-xr-x.1根目录10469 Jun 26 2019 ssh副本id-rwxr-xr-x.1根目录419208 Jun 26 2019 ssh密钥根目录-rwxr-xr-x.1根目录2019 10月9日ssh\U ssh\U授权密钥-rwxr-xr-x。1根根28000根2019年10月9日sss\U ssh_knownhostsproxy@VonC感谢您提出解决此问题的建议。