Package com.jk.core.ssh
Class JKSSHClient
java.lang.Object
com.jk.core.ssh.JKSSHClient
This class represents an SSH client for executing commands on a remote host.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Constructor Summary
ConstructorsConstructorDescriptionJKSSHClient
(String host, int port, String username, String password) This method constructs a newJKSSHClient
. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
callCommand
(String host, int port, String username, String password, String command) This method calls an SSH command on a remote host using the provided parameters.static void
This main method tests the SSH client.runCommand
(String command) This method executes a command on the remote host.
-
Constructor Details
-
JKSSHClient
This method constructs a newJKSSHClient
.- 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
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
This main method tests the SSH client.- Parameters:
args
- the command line arguments.- Throws:
IOException
- if an I/O exception has occurred.
-