jenkins中使用rsync, scp命令

Posted Oops!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jenkins中使用rsync, scp命令相关的知识,希望对你有一定的参考价值。

jenkins 中使用 rsync 命令 是出现一些错误输出

Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
 
和其他
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
 
在 /etc/passwd中 修改 jenkins 为 /bin/bash
jenkins:x:494:494:Jenkins Automation Server:/var/lib/jenkins:/bin/bash
 
在客户端 
/etc/ssh/ssh_config 中修改

# StrictHostKeyChecking no

 

在 jenkins 服务器切换到 jenkins账户  su - jenkins

创建密钥

 ssh-keygen

Your identification has been saved in /var/lib/jenkins/.ssh/id_rsa.
Your public key has been saved in /var/lib/jenkins/.ssh/id_rsa.pub.

将公钥内容 id_rsa.pub 拷贝到客户端 /root/.ssh/authorized_keys 文件内 

执行输出 结果为  success 

 

 rsync -avzP /data/go/*/*/* [email protected]:/data/website/
sending incremental file list
adserver-beta
        3632   0%    0.00kB/s    0:00:00
    13227248 100%   85.79MB/s    0:00:00 (xfer#1, to-check=0/1)

sent 97 bytes  received 21883 bytes  43960.00 bytes/sec
total size is 13227248  speedup is 601.79
Finished: SUCCESS

 

以上是关于jenkins中使用rsync, scp命令的主要内容,如果未能解决你的问题,请参考以下文章

Linux中传输文件的scp和rsync命令

Linux远程复制scp和rsync区别

Linux scp命令详解

linux服务器间传文件命令scp,rsync以及排除部分文件夹

scp命令

linux下ssh远程登录/scp远程复制文件/rsync远程同步命令的自动登录