我想使用scp/ssh上传一些文件到服务器。我发现我需要使用基于证书的身份验证,但问题是怎么做?我真正想做的是使用与git相同的证书-a存储在Jenkins中的带密码的ssh cert。但是,我不知道如何做--代码片段生成器没有明显的选项。其他人是怎么做的?有没有一个未公开的特性可以做到这一点?
wgx48brx1#
withCredentials([sshUserPrivateKey(credentialsId: "yourkeyid", keyFileVariable: 'keyfile')]) { stage('scp-f/b') { sh 'scp -i ${keyfile} do sth here' } }
也许这就是你想要的。安装Credentials Plugin和Credentials Binding Plugin。添加一些凭据,然后您将获得“yourkeyid”,将此凭据绑定到keyFileVariable、passphraseVariable等。更多的细节和文档可以在Jenkins Credentials Binding Plugin,Credentials Binding Plugin docs,Credentials Plugin,SSH Pipeline Steps插件的Github站点上找到
Credentials Plugin
Credentials Binding Plugin
vfhzx4xs2#
如果你安装了SSH Agent plugin,你可以使用ssh-agent pipeline步骤来运行一个shell脚本,并激活一个ssh代理。ssh-agent获取一个Jenkins凭证ID(一个带密码的ssh证书,就像你为git所做的那样)。
ssh-agent
2条答案
按热度按时间wgx48brx1#
也许这就是你想要的。安装
Credentials Plugin
和Credentials Binding Plugin
。添加一些凭据,然后您将获得“yourkeyid”,将此凭据绑定到keyFileVariable、passphraseVariable等。更多的细节和文档可以在Jenkins Credentials Binding Plugin,Credentials Binding Plugin docs,Credentials Plugin,SSH Pipeline Steps插件的Github站点上找到
vfhzx4xs2#
如果你安装了SSH Agent plugin,你可以使用
ssh-agent
pipeline步骤来运行一个shell脚本,并激活一个ssh代理。ssh-agent
获取一个Jenkins凭证ID(一个带密码的ssh证书,就像你为git所做的那样)。