Examples of SshClient


Examples of com.consol.citrus.ssh.client.SshClient

        Map<String, SshClient> clients = beanDefinitionContext.getBeansOfType(SshClient.class);

        Assert.assertEquals(clients.size(), 2);

        // 1st client
        SshClient client = clients.get("sshClient1");
        Assert.assertEquals(client.getEndpointConfiguration().getHost(), "localhost");
        Assert.assertEquals(client.getEndpointConfiguration().getPort(), 2222);
        Assert.assertEquals(client.getEndpointConfiguration().getUser(), "citrus");
        Assert.assertNull(client.getEndpointConfiguration().getPassword());
        Assert.assertNull(client.getEndpointConfiguration().getPrivateKeyPath());
        Assert.assertNull(client.getEndpointConfiguration().getPrivateKeyPassword());
        Assert.assertNull(client.getEndpointConfiguration().getKnownHosts());
        Assert.assertEquals(client.getEndpointConfiguration().getCommandTimeout(), 1000 * 60 * 5);
        Assert.assertEquals(client.getEndpointConfiguration().getConnectionTimeout(), 1000 * 60 * 1);
        Assert.assertFalse(client.getEndpointConfiguration().isStrictHostChecking());
        Assert.assertNotNull(client.getEndpointConfiguration().getXmlMapper());

        // 2nd client
        client = clients.get("sshClient2");
        Assert.assertEquals(client.getEndpointConfiguration().getHost(), "dev7");
        Assert.assertEquals(client.getEndpointConfiguration().getPort(), 10022);
        Assert.assertEquals(client.getEndpointConfiguration().getUser(), "foo");
        Assert.assertEquals(client.getEndpointConfiguration().getPassword(), "bar");
        Assert.assertEquals(client.getEndpointConfiguration().getPrivateKeyPath(), "classpath:com/consol/citrus/ssh/citrus.priv");
        Assert.assertEquals(client.getEndpointConfiguration().getPrivateKeyPassword(), "consol");
        Assert.assertEquals(client.getEndpointConfiguration().getKnownHosts(), "classpath:com/consol/citrus/ssh/known_hosts");
        Assert.assertEquals(client.getEndpointConfiguration().getCommandTimeout(), 10000);
        Assert.assertEquals(client.getEndpointConfiguration().getConnectionTimeout(), 5000);
        Assert.assertTrue(client.getEndpointConfiguration().isStrictHostChecking());
        Assert.assertNotNull(client.getEndpointConfiguration().getXmlMapper());
    }
View Full Code Here

Examples of com.davfx.ninio.ssh.SshClient

          }
        }

        if (client == null) {
         
          client = new SshClient().withLogin(login).withPassword(password);
          if (host != null) {
            client.withHost(host);
          }
          if (port >= 0) {
            client.withPort(port);
View Full Code Here

Examples of com.google.code.sshd.SshClient

            }
        }

        // TODO: implement sending a direct command

        SshClient client = null;
        try {
            client = SshClient.setUpDefaultClient();
            client.start();
            ClientSession session = client.connect(host, port);
            session.authPassword(user, password);
            ClientChannel channel = session.createChannel("shell");
            channel.setIn(new ConsoleReader().getInput());
            channel.setOut(System.out);
            channel.setErr(System.err);
            channel.open();
            channel.waitFor(ClientChannel.CLOSED, 0);
        } catch (Throwable t) {
            t.printStackTrace();
            System.exit(1);
        } finally {
            try {
                client.stop();
            } catch (Throwable t) { }
        }
        System.exit(0);
    }
View Full Code Here

Examples of com.sshtools.j2ssh.SshClient

        connectionInfo = getConnectionInfo( host, port, username );

        if( log.isDebugEnabled() ) log.debug( connectionInfo + " - Attempting to Open Connection." );

        // Initialize the SSH library
        sshClient = new SshClient();
        sshClient.setSocketTimeout( 30000 );
        SshConnectionProperties properties = new SshConnectionProperties();
        properties.setHost( host );
        properties.setPort( port );
        properties.setPrefPublicKey("ssh-dss");
View Full Code Here

Examples of com.sshtools.j2ssh.SshClient

        connectionInfo = getConnectionInfo( host, port, username );

        if( log.isDebugEnabled() ) log.debug( connectionInfo + " - Attempting to Open Connection." );

        // Initialize the SSH library
        sshClient = new SshClient();
        sshClient.setSocketTimeout( 30000 );
        SshConnectionProperties properties = new SshConnectionProperties();
        properties.setHost( host );
        properties.setPort( port );
View Full Code Here

Examples of com.sshtools.j2ssh.SshClient

        checkConnection(instance, ec2client);
    }

    public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException {
        String shellCmd = createShellCmd(jobExecutionContext);
        SshClient sshClient = new SshClient();
        sshClient.setSocketTimeout(SOCKET_TIMEOUT);
        SshConnectionProperties properties = new SshConnectionProperties();
        properties.setHost(this.instance.getPublicDnsName());
        properties.setPort(SSH_PORT);

        // Connect to the host
        try
        {
            String outParamName;
            OutputParameterType[] outputParametersArray = jobExecutionContext.getApplicationContext().
                    getServiceDescription().getType().getOutputParametersArray();
            if(outputParametersArray != null) {
                outParamName = outputParametersArray[0].getParameterName();
            } else {
                throw new GFacProviderException("Output parameter name is not set. Therefore, not being able " +
                        "to filter the job result from standard out ", jobExecutionContext);
            }

            sshClient.connect(properties, new HostKeyVerification() {
                public boolean verifyHost(String s, SshPublicKey sshPublicKey) throws TransportProtocolException {
                    log.debug("Verifying Host: " + s);
                    return true;
                }
            });

            // Initialize the authentication data.
            PublicKeyAuthenticationClient publicKeyAuth = new PublicKeyAuthenticationClient();
            publicKeyAuth.setUsername("ec2-user");
            SshPrivateKeyFile file = SshPrivateKeyFile.parse(new File(PRIVATE_KEY_FILE_PATH));
            SshPrivateKey privateKey = file.toPrivateKey("");
            publicKeyAuth.setKey(privateKey);

            // Authenticate
            int result = sshClient.authenticate(publicKeyAuth);
            if(result== AuthenticationProtocolState.FAILED) {
                throw new GFacProviderException("The authentication failed", jobExecutionContext);
            } else if(result==AuthenticationProtocolState.PARTIAL) {
                throw new GFacProviderException("The authentication succeeded but another"
                        + "authentication is required", jobExecutionContext);
            } else if(result==AuthenticationProtocolState.COMPLETE) {
                log.info("ssh client authentication is complete...");
            }

            SessionChannelClient session = sshClient.openSessionChannel();
            log.info("ssh session successfully opened...");
            session.requestPseudoTerminal("vt100", 80, 25, 0, 0, "");
            session.startShell();
            session.getOutputStream().write(shellCmd.getBytes());
View Full Code Here

Examples of com.sshtools.j2ssh.SshClient

      try{
        ConfigurationLoader.initialize(false);
      }catch(IOException e){
        setTask(TASK_ERROR,new String[] {m_errorPrefix+"configuration: "+e.getMessage() });
      }
      m_ssh = new SshClient();

      try{
        m_ssh.setSocketTimeout(m_details.getTimeout()*1000);
        m_ssh.connect(
            m_details.getServer(),
View Full Code Here

Examples of com.sshtools.j2ssh.SshClient

                }
            });

        ConfigurationLoader.initialize(false);

        ssh = new SshClient();
        ssh.setSocketTimeout(30000);

        //SshConnectionProperties properties = new SshConnectionProperties();
        //properties.setHost(host);
        //properties.setPort(port);   
View Full Code Here

Examples of com.sshtools.j2ssh.SshClient

    private boolean login()
    {
        try
        {
            ssh = new SshClient();
            //ssh.setSocketTimeout(timeout);
            //ssh.setKexTimeout(timeout);
           
            Log.debug("Host: "+properties.getHost()+":"+properties.getPort());
View Full Code Here

Examples of net.schmizz.sshj.SSHClient

  }

  public Session getSession(String hostAddress) throws IOException {
    try {
      if (sshClient == null) {
        sshClient = new SSHClient();
      }
      if (getSSHClient().isConnected())
        return getSSHClient().startSession();

      KeyProvider pkey = getSSHClient().loadKeys(getPrivateKeyLoc(), getKeyPass());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.