2012-10-19 72 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不兼容,以及其中包含@符号的用户名。他们提供了\ @或者升级服务器的转义。这有帮助吗? –