如何在ant文件中为ipv6地址执行scp

时间:2015-07-29 16:40:06

标签: java linux ant ssh scp

我正在尝试使用apache-ant进行安全复制(scp)文件。我正在使用JSCH库来做到这一点。 目前,我能够使用ant任务为ipv4安全复制文件,其中scp无法获取ipv6地址。

以下是我的蚂蚁文件:                            

CLI输出:

$> ant  config-open-api -lib ~/dev/apache-ant-1.9.5/lib/jsch-0.1.50.jar -Dmachine.ip=fd01:0:101:2606:0:eff:fe57:9336 -Dmachine.root.username=root -Dmachine.root.password=p@ssw0rd

    vboda-mbpro15:functional vboda$ ~/dev/apache-ant-1.9.5/bin/ant  config-open-api -lib ~/dev/apache-ant-1.9.5/lib/jsch-0.1.50.jar -Dvcopssuitevm.ip=fd01:0:101:2606:0:eff:fe57:9336 -Dvcopssuitevm.root.username=root -Dvcopssuitevm.root.password=vmware
    Buildfile: /Users/vboda/perforce/depot/om/main/qe/platform/functional/build.xml

    config-open-api:
         [echo] this is echo!
          [scp] Connecting to fd01:22

    BUILD FAILED
    /Users/vboda/perforce/depot/om/main/qe/platform/functional/build.xml:4: com.jcraft.jsch.JSchException: java.net.UnknownHostException: fd01
        at com.jcraft.jsch.Util.createSocket(Util.java:344)
        at com.jcraft.jsch.Session.connect(Session.java:215)
        at com.jcraft.jsch.Session.connect(Session.java:183)
        at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:225)
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.upload(Scp.java:348)
        at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:244)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:435)
        at org.apache.tools.ant.Target.performTasks(Target.java:456)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
        at org.apache.tools.ant.Main.runBuild(Main.java:853)
        at org.apache.tools.ant.Main.startAnt(Main.java:235)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
    Caused by: java.net.UnknownHostException: fd01
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at java.net.Socket.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)
        at com.jcraft.jsch.Util.createSocket(Util.java:338)

我一直在网上寻找解决方案,但找不到任何解决方案。真的很感激,如果有人能让我知道可能的解决方案来解决它

2 个答案:

答案 0 :(得分:0)

ssh州的手册页:

  

可以通过将地址括在方括号中来指定IPv6地址。

但我不确定如何在你的java魔法中推动它......

答案 1 :(得分:0)

似乎ipv6主机名的ant scp任务中存在错误。解析ipv6的主机名是不正确的。请参阅错误https://bz.apache.org/bugzilla/show_bug.cgi?id=59160