Jenkins && Pipeline Public/Private Key errors

1. Jenkins  test configuration failed:

jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [prop-idm.dxctech.tk-tianxia]. Message [Auth fail]]


Solution:

run cmd as below:

[tx@prop-idm .ssh]$ cat id_rsa.pub >> authorized_keys

 

2. Pipeline failed

node('slave1') {
     stage('update idm version'){
        sshagent(credentials:['idm-version-update']){
           sh "ssh -v -o StrictHostKeyChecking=no -l tiaxia prop-idm.dxctech.tk '/home/tiaxia/workshop/VPC-IDM-service/update-version.sh ${version}' "
        }
       
    }

    stage('Push to ftp Server'){
        sh "scp /opt/mount1/jenkinsHome/workspace/Propel-IDM-Distribution2/idm-vpc-part/target/packagetmp/idm-service-1.10.0-VPC1.22/WEB-INF/lib/*.jaruftp@ec4t01705.itcs.entsvcs.net:/var/ftp/dxc-vpc-idm"
    }

}

[Pipeline] node
Running on ec4t01663.itcs.entsvcs.net_slave1 in /opt/mount1/jenkinsHome/workspace/update-idm-version
[Pipeline] {
[Pipeline] stage
[Pipeline] { (update idm version)
[Pipeline] sshagent
[ssh-agent] Using credentials tiaxia(idm-version-update) (prop-idm.dxctech.tk)
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Exec ssh-agent (binary ssh-agent on a remote machine)
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-3iPZUGmAul7r/agent.101746
SSH_AGENT_PID=101748
$ ssh-add /opt/mount1/jenkinsHome/workspace/update-idm-version@tmp/private_key_5963022477772105576.key
Identity added: /opt/mount1/jenkinsHome/workspace/update-idm-version@tmp/private_key_5963022477772105576.key (/opt/mount1/jenkinsHome/workspace/update-idm-version@tmp/private_key_5963022477772105576.key)
[ssh-agent] Started.
[Pipeline] {
[Pipeline] sh
[update-idm-version] Running shell script
+ ssh -v -o StrictHostKeyChecking=no -l tiaxia prop-idm.dxctech.tk '/home/tiaxia/workshop/VPC-IDM-service/update-version.sh 44'
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 56: Applying options for *
debug1: Connecting to prop-idm.dxctech.tk [15.107.26.32] port 22.
debug1: Connection established.
debug1: identity file /home/jenkins/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jenkins/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jenkins/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jenkins/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jenkins/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jenkins/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jenkins/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/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
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to prop-idm.dxctech.tk:22 as 'tiaxia'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:bywounkjzyPiGtoPw1397lEqKcFrm64jskiYJ3bPqkM
debug1: Host 'prop-idm.dxctech.tk' is known and matches the ECDSA host key.
debug1: Found key in /home/jenkins/.ssh/known_hosts:11
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_25929)

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_25929)

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /opt/mount1/jenkinsHome/workspace/update-idm-version@tmp/private_key_5963022477772105576.key
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Offering RSA public key: /home/jenkins/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/jenkins/.ssh/id_dsa
debug1: Trying private key: /home/jenkins/.ssh/id_ecdsa
debug1: Trying private key: /home/jenkins/.ssh/id_ed25519
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 101748 killed;
[ssh-agent] Stopped.
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[Pipeline] }
[Pipeline] // sshagent
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 255
Finished: FAILURE


Solution:

Add jenkins server public key to prop-idm.dxctech.tk:/home/tiaxia/.ssh/authorized_keys


3. 

 stage('Push to ftp Server'){
        sh "scp /opt/mount1/jenkinsHome/workspace/Propel-IDM-Distribution2/idm-vpc-part/target/packagetmp/idm-service-1.10.0-VPC1.22/WEB-INF/lib/*.jaruftp@ec4t01705.itcs.entsvcs.net:/var/ftp/dxc-vpc-idm"
    }

[Pipeline] { (Push to ftp Server)
[Pipeline] sh
[update-idm-version] Running shell script
+ scp /opt/mount1/jenkinsHome/workspace/Propel-IDM-Distribution2/idm-vpc-part/target/packagetmp/idm-service-1.10.0-VPC1.22/WEB-INF/lib/idm-authn-1.10.0-VPC1.22.jar uftp@ec4t01705.itcs.entsvcs.net:/var/ftp/dxc-vpc-idm
Host key verification failed.
lost connection
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

Solution

Check the permissions on your homedirectory, .ssh directory, and the authorized_keys file: Ifyour ssh server is running with ‘StrictModes on’, it will refuse to use yourpublic keys in the ~/.ssh/authorized_keys file. Your home directory should bewritable only by you, ~/.ssh should be 700, and authorized_keys should be 600

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值