By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,650 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,650 IT Pros & Developers. It's quick & easy.

running a command on a remote computer using ant sshexec task ?

P: 2
I am new to this subject, Apache Ant, I want to run a command on a remote computer using ant sshexec task. this is part of my undergraduate thesis. I have to solve this problem as soon as possible. there is a target like that :

Expand|Select|Wrap|Line Numbers
  1. <target id="9" name="connectrun">
  2. <sshexec host="192.168.1.34"
  3.    username="MCT"
  4.    password="Kocaeli41"
  5.    trust="true" 
  6.    verbose="true"
  7.    command="cmd /c dir C:\">
  8.    </sshexec>
  9. </target>
I use ant version 1.8.2 and jsch-0.1.48.jar. OSs are windows 7 each of computer. And I turned off windows firewalls When I run the target, I take this error :

Expand|Select|Wrap|Line Numbers
  1. com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: connect
  2. at com.jcraft.jsch.Util.createSocket(Util.java:341)
  3. at com.jcraft.jsch.Session.connect(Session.java:182)
  4. at com.jcraft.jsch.Session.connect(Session.java:150)
  5. at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:223)
  6. at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:190)
  7. at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
  8. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  9. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  10. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  11. at java.lang.reflect.Method.invoke(Method.java:601)
  12. at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
  13. at org.apache.tools.ant.Task.perform(Task.java:348)
  14. at org.apache.tools.ant.Target.execute(Target.java:390)
  15. at org.apache.tools.ant.Target.performTasks(Target.java:411)
  16. at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
  17. at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
  18. at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
  19. at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
  20. at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284)
  21. at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
  22. at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
  23. Caused by: java.net.ConnectException: Connection refused: connect
  24. at java.net.DualStackPlainSocketImpl.connect0(Native Method)
  25. at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
  26. at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
  27. at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
  28. at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
  29. at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
  30. at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
  31. at java.net.Socket.connect(Socket.java:579)
  32. at java.net.Socket.connect(Socket.java:528)
  33. at java.net.Socket.<init>(Socket.java:425)
  34. at java.net.Socket.<init>(Socket.java:208)
  35. at com.jcraft.jsch.Util.createSocket(Util.java:335)
Jun 21 '12 #1

✓ answered by hasanfellah

I have already installed freeSSHd server on my remote windows server. and I have set SSH listening port as 22, this port is default, of course you can change. For other people that want to help about this topic : Don't forget we will use username and password that created by SSH server. Be careful don't use windows username. Thanks.

Share this Question
Share on Google+
1 Reply


P: 2
I have already installed freeSSHd server on my remote windows server. and I have set SSH listening port as 22, this port is default, of course you can change. For other people that want to help about this topic : Don't forget we will use username and password that created by SSH server. Be careful don't use windows username. Thanks.
Jun 21 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.