Jenkins"Execute shell"是否可以执行SSH命令?
Jenkins有许多前置和后置构建选项,专门用于SSH类型命令但是我有一个脚本可以同时构建,然后执行SCP和SSH命令.Jenkins是否强迫用户将构建脚本分解为多个步骤?
"Execute Shell"是我试图执行SSH命令的那个,但是我没有成功.
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /var/lib/jenkins/.ssh/identity
debug1: Trying private key: /var/lib/jenkins/.ssh/id_rsa
debug1: Trying private key: /var/lib/jenkins/.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,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,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,password
debug1: No more authentication methods to try.
Permission denied (publickey,password).
SSH Access not available for build engine
Run Code Online (Sandbox Code Playgroud)
gai*_*ige 16
只要您使用公钥,您就可以通过ssh并发送命令来复制文件scp.我们使用它来生成一些特定的进程,并发布某些无法通过现有命令推送的工件,原因有多种.
有必要注意您使用的是哪些密钥以及您在远程服务器上寻址的用户.通常,我们-i在ssh中使用显式参数,并且我们总是使用显式用户名来确保一切都按预期进行
ssh -i <key_path> <user>@<fqdn_host> <command>
Run Code Online (Sandbox Code Playgroud)
如果你在脚本中这样做,你应该没事.当然,您的Jenkins进程必须能够读取密钥文件,并且您需要确保密钥安装在两端.
我还强烈建议使用ssh的内置策略控件来控制:
特别是,您可以使用~/.ssh/authorized_keys作为ssh/scp命令目标的主机上的设置来限制可以附加(host=)甚至预加载命令的主机,以便特定键始终只执行一个特定命令(command=) .
对于真正的冒险者,您可以指定a command=并将命令发送到受限制的shell命令,该命令限制目录访问或命令访问.
| 归档时间: |
|
| 查看次数: |
34696 次 |
| 最近记录: |