一、端口问题形成的链接失败java
remote-prepare: [sshexec] Connecting to 123.123.123.123:22 java.net.ConnectException: Connection timed out
解决办法web
修改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>
二、显示无权限服务器
com.jcraft.jsch.JSchException: Auth fail
缘由:为了安全起见,服务器链接不是使用用户名密码方式,而是使用秘钥文件,因此须要把password换成keyfileless
<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标签的修改须要记得把全部用到的地方都改掉,避免遗漏ssh
三、显示没有提供密码或者密码短语ui
neither password nor passphrase for user root has been given. Can't authenticate.
添加passphrase
.net
<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>