gpt4 book ai didi

ssh - 为什么 rsync 与 Jenkins 失败

转载 作者:太空宇宙 更新时间:2023-11-03 17:17:27 33 4
gpt4 key购买 nike

在 CentOS 6.4 上 rsync 与 jenkins 一起使用作为执行 shell 命令时,失败:

[workspace] $ /bin/sh -xe /tmp/hudson3424899639384884888.sh
+ rsync -av /var/lib/jenkins/jobs/myjob/workspace/target/classes/ myuser@myserver.com:/home/myuser/test
rsync: Failed to exec ssh: Permission denied (13)
rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.6]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(600) [sender=3.0.6]

但是,它可以从命令行运行:

su jenkins
rsync -av /var/lib/jenkins/jobs/myjob/workspace/target/classes/ myuser@myserver.com:/home/myuser/test
sending incremental file list

sent 17875 bytes received 83 bytes 3990.67 bytes/sec
total size is 1981027 speedup is 110.31

要使其在 jenkins 中也能正常工作,还需要做什么?

最佳答案

问题出在 CentOS 上安装的 SElinux,由于某种原因阻止了 rsync 的 ssh。

这是/var/log/messages 中的一行,表示 ssh 被阻止:

Jun 12 13:45:59 myserver kernel: type=1400 audit(1434109559.911:33346): avc:  denied  { execute } for  pid=11862 comm="rsync" name="ssh" dev=dm-1 ino=11931741 scontext=unconfined_u:system_r:rsync_t:s0 tcontext=system_u:object_r:ssh_exec_t:s0 tclass=file

目前我们在服务器上禁用了 SElinux,正确的解决方案是创建自定义策略模块 (1)

关于ssh - 为什么 rsync 与 Jenkins 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30743180/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com