Class JKSSHClient

java.lang.Object
com.jk.core.ssh.JKSSHClient

public class JKSSHClient extends Object
This class represents an SSH client for executing commands on a remote host.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Details

    • JKSSHClient

      public JKSSHClient(String host, int port, String username, String password)
      This method constructs a new JKSSHClient.
      Parameters:
      host - Specifies the remote host.
      port - Specifies the port to connect to on the remote host.
      username - Specifies the SSH user name.
      password - Specifies the SSH password.
  • Method Details

    • callCommand

      public static String callCommand(String host, int port, String username, String password, String command) throws IOException
      This method calls an SSH command on a remote host using the provided parameters.
      Parameters:
      host - Specifies the remote host.
      port - Specifies the port to connect to on the remote host.
      username - Specifies the SSH user name.
      password - Specifies the SSH password.
      command - Specifies the command to execute on the remote host.
      Returns:
      the response from the remote command execution.
      Throws:
      IOException - if an I/O exception has occurred.
    • runCommand

      public String runCommand(String command)
      This method executes a command on the remote host.
      Parameters:
      command - Specifies the command to execute on the remote host.
      Returns:
      the response from the remote command execution.
    • main

      public static void main(String[] args) throws IOException
      This main method tests the SSH client.
      Parameters:
      args - the command line arguments.
      Throws:
      IOException - if an I/O exception has occurred.