在带有 ssh、scp 或 sftp 的 jenkins 管道中使用 ssh 凭据 [英] Use ssh credentials in jenkins pipeline with ssh, scp or sftp
问题描述
我想使用 scp/ssh 将一些文件上传到服务器.我发现我需要使用基于证书的身份验证,但问题是如何?我真正想做的是使用与 git 一起使用的相同类型的凭据 - 存储在 Jenkins 中的密码 ssh 证书.但是,我不知道该怎么做 - 片段生成器对此没有明显的选择.
I want to use scp/ssh to upload some files to a server. I discover that I need to use certificate-based authentication, but the question is how? Really what I want to do is to use the same sort of credentials I use with git - passworded ssh cert stored in Jenkins. However, I can't work out how to - the snippet generator has no obvious option for that.
其他人是做什么的?是否有未记录的功能可以做到这一点?
What do others do? Is there an undocumented feature that would do this?
推荐答案
如果你安装了 SSH 代理插件 你可以使用 ssh-代理
管道步骤,以在 ssh-agent 处于活动状态时运行 shell 脚本.ssh-agent
需要一个 Jenkins 凭证 ID(一个带密码的 ssh 证书,就像你为 git 所拥有的一样).
If you install the SSH Agent plugin you can use the ssh-agent
pipeline step to run a shell script with an ssh-agent active. The ssh-agent
takes a Jenkins credentials ID (a passworded ssh cert, like the one you have for git).
这篇关于在带有 ssh、scp 或 sftp 的 jenkins 管道中使用 ssh 凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!