Java code to connect to remote windows machine from local machine

Hi,
I have developed a code to connecting remote windows M/C from local M/C by using SSH2 (ganymed-ssh2-build209.jar) API. when I run the code its giving below error. Can any one please help me how to resolve it. And also please let me know, is there any other way to connect remote windows system using java code.
Exception.
java.io.IOException: There was a problem while talking to <host name>:22
  at ch.ethz.ssh2.Connection.connect(Connection.java:642)
  at ch.ethz.ssh2.Connection.connect(Connection.java:460)
  at Connect.RemoteServer.ConnectWindowsServer.runCommand(ConnectWindowsServer.java:55)
  at Connect.RemoteServer.ConnectWindowsServer.main(ConnectWindowsServer.java:27)
Caused by: java.net.ConnectException: Connection refused: connect
  at java.net.PlainSocketImpl.socketConnect(Native Method)
  at java.net.PlainSocketImpl.doConnect(Unknown Source)
  at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
  at java.net.PlainSocketImpl.connect(Unknown Source)
  at java.net.SocksSocketImpl.connect(Unknown Source)
  at java.net.Socket.connect(Unknown Source)
  at ch.ethz.ssh2.transport.TransportManager.initialize(TransportManager.java:299)
  at ch.ethz.ssh2.Connection.connect(Connection.java:591)
  ... 3 more
JAVA Code
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.Session;
public void setAuthenticationInfo(String hostname, String username,String password) {
       this.host = hostname;
       this.userid = username;
       this.password = password;      
       this.recentCommand = "";     
       System.out.println("setting authentication info completed for host=" + host );
  public void runCommand() throws Exception {
try{
        // Setup ssh session with endpoint
       System.out.println("starting connection with " + host);
       Connection connection = new Connection(host);
       System.out.println("connection object created..");
       connection.connect();
       System.out.println("Connect to connection");
       connection.authenticateWithPassword(userid,password);
       System.out.println(connection.isAuthenticationComplete());
       Session session = connection.openSession();
      System.out.println("connected");
  }catch (Exception e) {
  e.printStackTrace();
Regards,
Praveen

Hi baftos,
I tried to telnet remote windows machine from my local machine on port 23, its not connected and given error message like "Connect failed".
As your response, if we can telnet to remote windows machine from local machine then we can connect from Java. Is it correct ?.
Can you please help me to resolve this issue. And also please confirm the port (23) is correct, which I was used to connect remote machine from telnet.
Regards,
Praveen

Similar Messages

  • "Failed to connect to remote distribution point" on local machine

    I have a new System Center 2012 R2 setup. I only have a single server with Configuration Manager, SQL, and Distribution Point all on the same machine.
    The Configuration Manager Client Package is failing to load to the distribution point.
    Content Status says: "Distribution Manager failed to connect to distribution point
    ["Display=\\AcadSCCM01.Academic.local\"]MSWNET:["SMS_SITE=900"]\\AcadSCCM01.Academic.local\. Check your network and firewall settings."
    The distribution point is on the same machine as config manager, and the firewall is turned off. When I try to redistribute the package it fails again immediately.
    I checked distmgr.log and found the following:
    Translated server name AcadSCCM01.Academic.local to Academic.local\AcadSCCM01.Academic.local.               
    SMS_DISTRIBUTION_MANAGER             
    2/27/2015 5:15:54 PM    3640 (0x0E38)
    CWmi::Connect() failed to connect to \\AcadSCCM01.Academic.local\root\MicrosoftIISv2. Error = 0x8004100E               
    SMS_DISTRIBUTION_MANAGER             
    2/27/2015 5:15:54 PM    3640 (0x0E38)
    STATMSG: ID=2391 SEV=E LEV=M SOURCE="SMS Server" COMP="SMS_DISTRIBUTION_MANAGER" SYS=AcadSCCM01.Academic.local SITE=900 PID=2240 TID=3640 GMTDATE=Fri Feb 27 22:15:54.990 2015 ISTR0="["Display=\\AcadSCCM01.Academic.local\"]MSWNET:["SMS_SITE=900"]\\AcadSCCM01.Academic.local\"
    ISTR1="" ISTR2="" ISTR3="" ISTR4="" ISTR5="" ISTR6="" ISTR7="" ISTR8="" ISTR9="" NUMATTRS=1 AID0=404 AVAL0="["Display=\\AcadSCCM01.Academic.local\"]MSWNET:["SMS_SITE=900"]\\AcadSCCM01.Academic.local\"               
    SMS_DISTRIBUTION_MANAGER             
    2/27/2015 5:15:54 PM    3640 (0x0E38)
    ERROR DPConnection::ConnectRemoteIISManagementWMI() - Failed to connect to 
    AcadSCCM01.Academic.local. error = 0x8004100e        
    SMS_DISTRIBUTION_MANAGER             
    2/27/2015 5:15:54 PM    3640 (0x0E38)
    STATMSG: ID=2344 SEV=E LEV=M SOURCE="SMS Server" COMP="SMS_DISTRIBUTION_MANAGER" SYS=AcadSCCM01.Academic.local SITE=900 PID=2240 TID=3640 GMTDATE=Fri Feb 27 22:15:54.991 2015 ISTR0="["Display=\\AcadSCCM01.Academic.local\"]MSWNET:["SMS_SITE=900"]\\AcadSCCM01.Academic.local\"
    ISTR1="" ISTR2="" ISTR3="" ISTR4="" ISTR5="" ISTR6="" ISTR7="" ISTR8="" ISTR9="" NUMATTRS=1 AID0=404 AVAL0="["Display=\\AcadSCCM01.Academic.local\"]MSWNET:["SMS_SITE=900"]\\AcadSCCM01.Academic.local\"               
    SMS_DISTRIBUTION_MANAGER             
    2/27/2015 5:15:54 PM    3640 (0x0E38)

    Can you confirm that all the pre-requisites have been installed?
    Using the following Powershell:
    Get-WindowsFeature –ComputerName AcadSCCM01.Academic.local| Where Installed
    And compare against https://technet.microsoft.com/en-us/library/gg682077.aspx

  • Urget Help --- Please give me the core java code that connects to UNIX ser

    Can anyone provide the core java code that connects UNIX server after verifying credentials and allow to implements UNIX commands through java program?

    no, you don't want to do that.
    You want to connect yourself, which Java is quite capable of doing, rather than go through some 3rd party client program that's not only specific to a particular operating system but not guaranteed to be installed at any particular machine or if it is to be installed in such a way that you can start it from your Java program.
    And then there's the little matter of figuring out the external API to use that program in the way you intent to (if it has one).

  • Java.sql.SQLException: Connection to remote site no longer valid

    Hi
    Somebody can help me with this ?
    java.sql.SQLException: Connection to remote site no longer valid
    Sometimes this error message appears in the moment when the next code execute, the database is Informix 10
    public BeanOutParametersSMS siantelSMS(BeanArgumentsSMS bean)
    throws SQLException, NumberFormatException,
    NullPointerException, Exception {
    String sql = "execute procedure SP_SMS_MKT(?,?,?,?,?,?,?,?,?)";
    CallableStatement cs = null;
    ResultSet rs = null;
    BeanOutParametersSMS out = new BeanOutParametersSMS();
    String salesForce = "";
    try {
    cs = connection.prepareCall(sql);
    s.setString(1, bean.getAction());
    cs.setString(2, "R0" + bean.getRegion());
    cs.setString(3,bean.getCveclientesms());
    cs.setString(4,bean.getPuerto());
    cs.setString(5,bean.getCveproducto());
    if (cs.execute()) {
    rs = cs.getResultSet();
    if (rs.next()) {
         out.setActionInvoked(rs.getString(1));
    out.setCode(rs.getString(2));
    out.setPuerto(rs.getString(3));
    out.setCveproducto(rs.getString(4)); etc ....
    note. The stored procedure connecting with two databases (informix 10 & informix 9)

    Where do you close the connection and statement/result set?

  • Ifs Connection problem from local machine to Ifs server using API

    I am trying to make an API call to connect to Ifs database server running on different machine(UNIX) from local machine. I copied all jar files and /Lib/Ifs/Settings directory to my local machine. All these files are in the classpath of weblogic 6.0 environment. A jsp on weblogic server call a bean which has a responsibibility of connecting to Ifs server to get LibrarySession.
    From Visual Cafe 4.5 everything works fine but when i start weblogic 6.0 outside the visual cafe environment i get the error
    below. I included all the jar files and /Lib/Ifs/Settings in start up script of weblogic server
    Do you know if i missing some thing????
    java.lang.UnsatisfiedLinkError: do_open
    at oracle.jdbc.oci8.OCIDBAccess.do_open(Native Method)
    at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:309)
    at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:198)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:251)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at oracle.ifs.server.LibraryConnection.(LibraryConnection.java:235
    at oracle.ifs.server.ConnectionPool.createLibraryConnection(ConnectionPo
    ol.java:576)
    at oracle.ifs.server.ConnectionPool.(ConnectionPool.java:321)
    at oracle.ifs.server.S_LibraryService.(S_LibraryService.java:912)
    at oracle.ifs.server.S_LibraryService.startService(S_LibraryService.java
    :1129)
    at oracle.ifs.beans.LibraryService.connectLocal(LibraryService.java:408)
    at oracle.ifs.beans.LibraryService.connect(LibraryService.java:280)

    Have you installed the Oracle client software on the machine where you are running WebLogic and your custom iFS application (your bean)?
    It looks like the native JDBC libraries are not available to the JVM where WebLogic is executing your code. iFS uses JDBC to access the Oracle database, and it requires "thick" (OCI8) JDBC to do so. This means that you need Oracle client software to be installed (in an ORACLE_HOME directory) on a computer where you want to use the iFS API.
    If you do have the Oracle client software installed already, then perhaps the WebLogic environment isn't configured to have access to the native JDBC libraries. Normally, as long as $ORACLE_HOME/lib is in the LD_LIBRARY_PATH (on unix) or $ORACLE_HOME/bin is in the PATH (on windows), stuff should just work.
    See if you can find any information about including native libraries (for instance, to use JNI) in the WebLogic documentation. We don't certify with WebLogic, which is why I don't know the answer offhand.

  • Cannot run the code from local machine - works after deployment!!!

    Hi,
    I am totally new to application server. My problem is that the application code after it is 'deployed' from JDeveloper to Oracle Application Server - it works fine. I can go to the web application from the url and do a 'Submit' of forms and it works fine. The problem comes when I try to connect to dev. environment from local machine and try to do a 'Submit' (done for debugging purposes), I get a 500 Internal Server Error. Is there a configuration file or property I file I have to change? I am clueless.
    Basically addRequest can be considered as the 'Submit'.
    Javax.faces.FacesException: #{newRequestItem.addRequest}: javax.faces.el.EvaluationException: java.lang.IllegalAccessError: tried to access class javax.xml.rpc.FactoryFinder from class javax.xml.rpc.ServiceFactory
    At com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
    My application is built on ADF and JSF and connects to BPEL workflow and DRM. So it is using WebServices.
    Thanks.

    Hi,
    Top further pinpoint the issue, I can make the SSRS report work with the stored procedure by running
    SP_recompile 'myStoredProcedure'
    So, SQL Server has somehow messed up the execution plan for the sproc. But to repeat, executing the Sproc in Management Studio works just fine, I just look the exact sproc and parameters with SQL Profiler when it is not working in SSRS report, then run that
    same sproc manually and it works.
    After extensive debugging, it seems to raise from one specific SELECT row:
    SELECT
    cte.TIMEYEAR + 1 AS TIMEYEAR,
    where cte.TIMEYEAR is varchar. After changing that to
    SELECT
    CAST(cte.TIMEYEAR + 1 AS VARCHAR) AS TIMEYEAR,
    it started to work.
    What will probably remain forever unclear is that WHY the original select always breaks every now and then, and always starts to work with a simple sp_recompile. I could reproduce the error easily by running
    exec sp_msforeachtable @command1="EXEC sp_recompile '?'";
    after which the sproc raised error: "Conversion failed when converting nvarchar value 'Q1/2000' to data type int".
    ..aaaand then just by running SP_recompile 'myStoredProcedure' it again started working fine. I could reproduce this break & fix pair coherently.
    Still it makes no sense from SSRS report perspective, when sproc was broken in Management Studio query, it was always broken from SSRS report end as well, but sometimes when sproc was working from SSMS, it wasn't working from SSRS.

  • How can I connect to a windows server from a mac book pro

    How can I connect to a windows server from a mac book pre?

    I have a Dell Power Edge T110 ii in the office that has files and software I need to access when away from the office, when I am on the road I use a mac book pro and an iPad.
    I am sorry if I am being a bit vague but this is all new to me, I have tried 3 IT guys but they can not find a way.
    Any help is greatly appeciated.

  • How to boot only one group in remote machine from master machine

    Hi,
    I want to know the command to boot entire remote machine from master machine and how to boot only one group for remote machine from master machine.
    Thanks
    Amit

    You can boot the entire remote machine (after booting the Master machine) as follows:
    tmboot -B <lmid of remote machine> -l <lmid of remote machine>.
    For all the available tmboot options see http://download.oracle.com/docs/cd/E18050_01/tuxedo/docs11gr1/rfcm/rfcmd.html#wp1032112
    Regards,
    Malcolm.

  • Firefox 7.0 - Can not upload the file from local machine to server...gives "error 404 : file not found"

    firefox 7.0 - Can not upload the file from local machine to server...gives "error 404 : file not found"

    you have not understood my point
    how does this code will run on servlet when I want to upload a file from client's
    machine to server machine
    what I am doing is I am giving an option to the user that he/she can browse the file and then select any file and finally it's action is post in the jsp form for which I have sent the code
    All the computers are connected in LAN
    So how to upload a file from client's machine to server's machine
    Plz give me a solution

  • While trying to invoke the method java.lang.String.length() of an object loaded from local variable 'payload'

    Hi,
    Our PI is getting data from WebSphere MQ and pushing to SAP. So our sender CC is JMS and receiver is Proxy. Our PI version is 7.31.
    Our connectivity between the MQ is success but getting the following error while trying to read the payload.
    Text: TxManagerFilter received an error:
    [EXCEPTION]
    java.lang.NullPointerException: while trying to invoke the method java.lang.String.length() of an object loaded from local variable 'payload'
           at com.sap.aii.adapter.jms.core.channel.filter.ConvertJmsMessageToBinaryFilter.filter(ConvertJmsMessageToBinaryFilter.java:73)
           at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:204)
           at com.sap.aii.adapter.jms.core.channel.filter.InboundDuplicateCheckFilter.filter(InboundDuplicateCheckFilter.java:348)
           at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:204)
    I have searched SDN but couldn't fix it. Please provide your suggestion.
    With Regards
    Amarnath M

    Hi Amarnath,
    Where exactly you are getting this error?
    If you are getting at JMS Sender communication channel, try to stop and start the JMS communication channel and see the status, also use XPI Inspector to get the exact error log.
    for reference follow below blogs:
    Michal's PI tips: ActiveMQ - JMS - topics with SAP PI 7.3
    Michal's PI tips: XPI inspector - help OSS and yourself
    XPI Inspector

  • Uploading File to server from local machine

    how to Upload the File to server from local machine.
    Using java applet, how to upload the file to secure server.
    I dont know how to proceed the steps for uploading
    Reply me ASAP.......

    Hi Ozkantr,
    The osql utility is installed by SQL Server. You need to make sure the utility is installed on your colleague machine.
    To run SSIS package outside the BIDS, only the DTExec utility which is a client tool is not enough, the server components for Integration Services Service (SSIS runtime) is also required. To install SSIS runtime and DTExec utility, we must install the Integration
    Services shared feature from the SQL Server install media. So, you need to install SSIS service on the machine where the SSIS packages jobs run.
    References:
    http://www.bigator.com/2012/03/11/ways-to-execute-ssis-package/
    http://www.codeproject.com/Articles/219494/SSIS-Overview-Part-I
    Regards,
    +1
    You need to install Integration Services, which installs the necessary bytes on your computer and the SSIS service as well. The service can be disabled though, you don't need it to run packages.
    I wrote a blog post about it some time ago:
    When is DTEXEC installed?
    ps: osql is deprecated. Better start using sqlcmd.
    MCSE SQL Server 2012 - Please mark posts as answered where appropriate.

  • Can I transfer files to a machine from a machine w/a dead screen?

    Question:Can I transfer files to a machine from a machine w/a dead screen?

    If the MBP with the dead screen is otherwise functional, start it up in Target Disk Mode (Powering it up holding the T key/Firewire connecting the two MBPs).  If the other MBP sees the other MBP, you can click on the HDD icon and transfer files.
    Ciao.

  • How can I get one value from local machine registry

    how can I get one value from local machine registry, I would like read one value of regitry. I have windows NT workstation. I need it to find the full path of iexplore.exe, this value is in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE'
    Thanks.

    You can use the D2KWUTIL.pll library to read/write to the registry. You have to install the forms examples to get the library.
    The library d2kwut32.dll must also be installed at the clients.

  • Running CLIX commands from local machine

    Hello Experts,
    We have the following requirements in terms of clix commands
    Need to know the number of files in log/archieve/report folder - Is there any clix commands for this
    Want to run the clix commands manually from local machine (Windows), the mdm server is at linux environment. We dont want to automate the script and want to run when needed from local machine. Is that possible
    Thanks & Regards,
    Antony

    HI,A.Antony
    as far as i know ,clix can not count the number of files in the loglog/archieve/report folder.but there is a way out.you can get through the path:<driver>:\usr\sap\<instance>\MDS00\log to check it out.
    to run clix locally,you need to install the mdm-clix-7.1.<sp>.<patch>-win32.exe on your windows.then run the clix in the cmd circumstance.for the clix command Syntax,please refer to the MDM console reference guide,as for MDM7.1SP12,you may goto the Clix referece guide on help.sap.com.
    hope it helps.
    best regards
    Stephen

  • View pdf from local machine

    I have requirement of selecting a pdf from local system and previewing it before uploading.
    I am able to select the file and upload it but i am not able to preview it.
    I tried using navigateToURL(urlRequest,
    "_blank"); , but it is not able to show file from local path
    Can anyone please tell how can i show the file from local machine
    TIA

    Hi,
    is your code executed in Flash runtime (web/standalone application but played in Flash runtime) or in AIR runtime (or 3rd party projector)? That's important as only AIR hosted movie would have access to "file://" protocol when defining/using URLRequest (and then navigateToURL) that are outside of your application domain:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequest.html
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/package.html# navigateToURL()
    regards,
    Peter

Maybe you are looking for

  • TCP\IP Communication in the XI

    Hello, We have a scenario in which we have to communicate with a 3rd party system from our ECC system using the tcp\ip protocol. We used the XI by building a BPM with a transformation step that uses a java class, in which we opened a socket connectio

  • Order by in Parameter form for a formula col

    Hi, I have made a report for fast moving products and have ordered by on a formula column. Is there any way to select the order by (ascending or descending) in the parameter form at runtime for the same formula column. Instead of making two different

  • Decrypt Zip File with AES Cryptography

    Hi, I want to make a programm to decrypt a zip file with aes cryptography in java with gui. Our professor as a help they gave us that code [http://code.google.com/p/winzipaes/source/browse/winzipaes/src/de/idyl/crypto/zip/AesZipFileDecrypter.java?r=4

  • Is it possible to monitor State change of a .CSV file using powershell scripting ?

    Hi All, I just would like to know Is it possible to monitor State change of a .CSV file using powershell scripting ? We have SCOM tool which has that capability but there are some drawbacks in that for which we are not able to utilise that. So i woul

  • Help needed in connecting two midi keyboards to Logic Pro.

    Hey there, I would like to connect two midi keyboards to Logic Pro and enable each keyboard to trigger separate software instruments each. For example, one keyboard has guitar and the other has strings. I realise this must have something to do with m