一、端口問題形成的鏈接失敗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>