使用hudson时遇到的ssh上传问题

1、端口问题造成的连接失败

remote-prepare:
  [sshexec] Connecting to 123.123.123.123:22
java.net.ConnectException: Connection timed out

解决办法

修改build.xml,配置端口号 

<target name="remote-prepare">
	<sshexec host="${web.host}" username="${web.host.user}" port="2014" password="${web.host.pwd}" command="mkdir -p ${web.host.webroot}/../builds" trust="true" />
</target>

2、显示无权限

com.jcraft.jsch.JSchException: Auth fail

原因:为了安全起见,服务器连接不是使用用户名密码方式,而是使用秘钥文件,所以需要把password换成keyfile

<target name="remote-prepare">
	<sshexec host="${web.host}" username="${web.host.user}" port="2014" keyfile="${web.host.pwd}" command="mkdir -p ${web.host.webroot}/../builds" trust="true" />
</target>

端口号和keyfile标签的修改需要记得把所有用到的地方都改掉,避免遗漏

3、显示没有提供密码或者密码短语

neither password nor passphrase for user root has been given.  Can't authenticate.

添加passphrase

<target name="upload" depends="package" unless="noup">
	<fail unless="web.host.webroot" message="Please specify ${web.host.webroot}. eg, -Dwebroot.dir=/var/www/htdocs/" />
	<antcall target="remote-prepare" />
	<echo>Uploading build tar file to ${web.host.webroot}/../builds</echo>
	<echo>This will take a few minutes...</echo>
	<scp file="${build.file}" verbose="true" todir="${web.host.user}@${web.host}:${web.host.webroot}/../builds" passphrase="" port="2016" keyfile="${web.host.pwd}" trust="true" />
</target>


转载于:https://my.oschina.net/u/173975/blog/298311

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值