jenkins 配置 ssh连接远程服务器并执行相关命令

1、安装 Publish over SSH 插件

2、将将Jenkins所在机子的public_key添加到待部署服务器的root/.ssh/authorized_keys

3、系统管理设置界面拉到底部设置 Publish over SSH设置Passphrase(生成密码的时候输入的密码)、 Key(Private_key) 、ssh server Name(远程服务器Ip)、Hostname、UserNane

4、SSH服务器默认端口号是22,点击高级即可设置Port。

5、配置完成后,点击 Test Configuration 返回Success即证明Jenkins所在宿主机可以正常链接到待部署机。

6、勾选 Send files or execute commands over SSH before the build starts,即在构建开始之前,通过SSH登录目标服务器进行操作。

      勾选 Send files or execute commands over SSH after the build runs, 即在构建完成之后,通过SSH登录目标服务器进行操作。

7、在任务的构建模块 Send files or execute commands over SSH 设置Ssh server name  、Exec command

8、测试构建是否成功。

 

posted @ 2020-04-13 09:55  Console666  阅读(4637)  评论(0编辑  收藏  举报