2012-10-19 68 views
1

我想問你一些幫助。我的用戶名包含@符號時,如何使用scp任務?如何在Ant中逃脫@ SCP任務

我試圖在很多方面逃避角色,但它不工作。在下面的例子中,我的用戶名是[email protected]

<scp file="test.txt" todir="&quot;[email protected]&quot;:[email protected]:/" trust="true" sftp="true"/> 
<scp file="test.txt" todir="'[email protected]':[email protected]:/" trust="true" sftp="true"/> 
<scp file="test.txt" todir="user\@host.com:[email protected]:/" trust="true" sftp="true"/> 

但產量始終是相同的:

neither password nor keyfile for user "user has been given. Can't authenticate. 

請,反正是有強制任務正確地解析這個字符串?非常感謝你。

順便說一下,我不知道爲什麼,但與我目前的供應商不可能創建一個用戶名,而不追加主機名。

回答

2

我使用SCP的任務在我的build.xml,它的形式如下:

<scp file="package/ROOT.war" todir="[email protected]:~" trust="true" password="${password}"/> 

source of the SCP Task在功能parseUri(String uri)(線370)看,似乎任務可以支持用戶名一個@符號。這些限制似乎與具有路徑:或@在他們所看到此評論:

// user:[email protected]:/path notation 
// everything upto the last @ before the last : is considered 
// password. (so if the path contains an @ and a : it will not work) 

似乎代碼不支持此評論(如 martin clayton指出)。您還可以看到當密碼或密鑰文件丟失時觸發的錯誤。也許user:[email protected]:/path表示法中的密碼與用戶名和@的組合會導致問題?

+0

嗨,謝謝你的回答。我確定我的用戶名包含@符號。我現在只有Windows。但是當我使用任何GUI應用程序(如WinSCP或TotalCommander)時,連接就可以工作。是的,我必須使用SFTP連接而不是SCP。我閱讀了文檔(http://ant.apache.org/manual/Tasks/scp.html),密碼可以通過雙向傳遞。但這兩種方式都不起作用 – Bhiefer

+0

而當我通過TC連接時,我在標題中看到:user @ host.com @ ftp.host.com – Bhiefer

+0

此線程http://www.iprodeveloper.com/forums/aft/53169講座與舊版本的scp和sftp不兼容,以及其中包含@符號的用戶名。他們提供了\ @或者升級服務器的轉義。這有幫助嗎? –