weixin_49050320 2025-01-08 09:27 采纳率: 0%
浏览 20

jenkins流水线构建报错Permission denied, please try again.

在centos服务器中,有一台是ip3.18的脚本服务器,一台是ip3.22的服务器,他们之前可以互相ping通,能ssh到,但是在jenkins的流水线构建日志中报错,报错如下:

[Pipeline] { (check)
[Pipeline] sh
+ ssh -v root@10.168.3.18 sh /home/jenkins_sh/check.sh restcloud-mdm
OpenSSH_9.2p1 Debian-2+deb12u3, OpenSSL 3.0.14 4 Jun 2024
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 10.168.3.18 [10.168.3.18] port 22.
debug1: Connection established.
debug1: identity file /var/jenkins_home/.ssh/id_rsa type -1
debug1: identity file /var/jenkins_home/.ssh/id_rsa-cert type -1
debug1: identity file /var/jenkins_home/.ssh/id_ecdsa type -1
debug1: identity file /var/jenkins_home/.ssh/id_ecdsa-cert type -1
debug1: identity file /var/jenkins_home/.ssh/id_ecdsa_sk type -1
debug1: identity file /var/jenkins_home/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /var/jenkins_home/.ssh/id_ed25519 type -1
debug1: identity file /var/jenkins_home/.ssh/id_ed25519-cert type -1
debug1: identity file /var/jenkins_home/.ssh/id_ed25519_sk type -1
debug1: identity file /var/jenkins_home/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /var/jenkins_home/.ssh/id_xmss type -1
debug1: identity file /var/jenkins_home/.ssh/id_xmss-cert type -1
debug1: identity file /var/jenkins_home/.ssh/id_dsa type -1
debug1: identity file /var/jenkins_home/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.2p1 Debian-2+deb12u3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: compat_banner: match: OpenSSH_7.4 pat OpenSSH_7.4* compat 0x04000006
debug1: Authenticating to 10.168.3.18:22 as 'root'
debug1: load_hostkeys: fopen /var/jenkins_home/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
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: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:EYgDKjde2ws0XWHxcWB37ocqZHcRWYSdH4N91liFZr0
debug1: load_hostkeys: fopen /var/jenkins_home/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '10.168.3.18' is known and matches the ED25519 host key.
debug1: Found key in /var/jenkins_home/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /var/jenkins_home/.ssh/id_rsa 
debug1: Will attempt key: /var/jenkins_home/.ssh/id_ecdsa 
debug1: Will attempt key: /var/jenkins_home/.ssh/id_ecdsa_sk 
debug1: Will attempt key: /var/jenkins_home/.ssh/id_ed25519 
debug1: Will attempt key: /var/jenkins_home/.ssh/id_ed25519_sk 
debug1: Will attempt key: /var/jenkins_home/.ssh/id_xmss 
debug1: Will attempt key: /var/jenkins_home/.ssh/id_dsa 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: No credentials were supplied, or the credentials were unavailable or inaccessible
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)


debug1: No credentials were supplied, or the credentials were unavailable or inaccessible
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)


debug1: Next authentication method: publickey
debug1: Trying private key: /var/jenkins_home/.ssh/id_rsa
debug1: Trying private key: /var/jenkins_home/.ssh/id_ecdsa
debug1: Trying private key: /var/jenkins_home/.ssh/id_ecdsa_sk
debug1: Trying private key: /var/jenkins_home/.ssh/id_ed25519
debug1: Trying private key: /var/jenkins_home/.ssh/id_ed25519_sk
debug1: Trying private key: /var/jenkins_home/.ssh/id_xmss
debug1: Trying private key: /var/jenkins_home/.ssh/id_dsa
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
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.
root@10.168.3.18: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[Pipeline] }
[Pipeline] // stage

展开全部

  • 写回答

1条回答 默认 最新

  • 道友老李 JWE233286一种基于机器视觉的水表指针读数识别及修正的方法 专利发明者 2025-01-08 09:28
    关注
    让【道友老李】来帮你解答,本回答参考gpt编写,并整理提供,如果还有疑问可以点击头像关注私信或评论。
    如果答案让您满意,请采纳、关注,非常感谢!
    解决方案: 根据构建日志,可以看到在jenkins流水线中使用ssh连接到10.168.3.18服务器时报错,提示“load_hostkeys: fopen /var/jenkins_home/.ssh/known_hosts2: No such file or directory”。这个错误通常是由于Jenkins用户(一般是jenkins)没有正确的known_hosts文件导致的。 为了解决这个问题,可以尝试以下步骤:
    1. 确保/var/jenkins_home/.ssh目录存在,并且包含known_hosts文件,如果不存在可以手动创建一个空的known_hosts文件。
    2. 确认known_hosts文件的权限设置正确,通常应该是600(只有拥有者可以读写)。
    3. 如果在/var/jenkins_home/.ssh中没有known_hosts文件,也可以尝试将x.x.x.x替换成目标主机的IP地址(在该情况下为10.168.3.18)并间接ssh一次以生成known_hosts文件。 案例:
    # 创建known_hosts文件
    touch /var/jenkins_home/.ssh/known_hosts
    chmod 600 /var/jenkins_home/.ssh/known_hosts
    # 直接连接目标主机以生成known_hosts文件
    ssh root@10.168.3.18
    

    以上是针对Jenkins流水线构建日志中ssh报错的解决方案,如果问题仍然没有解决,可能需要进一步检查目标服务器的ssh配置、Jenkins用户的ssh配置等方面。

    评论
    编辑
    预览

    报告相同问题?

    手机看
    程序员都在用的中文IT技术交流社区

    程序员都在用的中文IT技术交流社区

    专业的中文 IT 技术社区,与千万技术人共成长

    专业的中文 IT 技术社区,与千万技术人共成长

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    客服 返回
    顶部