简体   繁体   中英

I can't able to SSH into remote server from Jenkins node using public and private Key

I am trying to remote ssh into remote linux machine from Jenkins node. I created public and private key in Jenkins node and copied the public key to authorized_keys in remote machine. But I can't able to remote into remote machine. Please check the logs below.

/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

Please let me know if any details are needed. Any help will be highly appreciated.

The issue can be closed. The issue is our jenkins server is in restricted network hence SSH won't work. We removed the restriction on firewall and the issue was fixed.

Following SSH Credentials Management with Jenkins , make sure you have:

  • registered the private key as an SSH credentials in jenkins
  • use a passphrase-less private key, or use the SSH Agent plugin
  • use both of those elements in your pipeline step

Example :

stage ('Deploy') {
    steps{
        sshagent(credentials : ['use-the-id-from-credential-generated-by-jenkins']) {

As noted in the comments , Jenkins uses a proxy command which means its execution user must have a ssh.config (like /etc/ssh/ssh_config ) which instructs any SSH call to go through that proxy.

If said proxy fails, that would explain the error message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM