类 SshdClient
- java.lang.Object
-
- tech.testnx.cah.common.net.ssh.SshdClient
-
- 所有已实现的接口:
ConnectSSH,HasSshExec,HasSshTunnel
public class SshdClient extends Object implements HasSshTunnel, HasSshExec
- 作者:
- Yun
-
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 booleanconnect()Connect with SSH Servervoiddisconnect()Disconnect with SSH ServerStringexecuteCommand(String command)Remote execute command or commands
Single command like: pwd
Multiple commands like: cd..; pwd; ls -al;
Open a new channel for each invokestatic SshdClientnewInstance(String sshServerHost, int sshServerPort, String userName, String password)static SshdClientnewInstance(String sshServerHost, int sshServerPort, String userName, Path privateKeyPath)static SshdClientnewInstance(String sshServerHost, String userName, String password)static SshdClientnewInstance(String sshServerHost, String userName, Path privateKeyPath)voidsetLocalPortForwarding(int localPort, String remoteHost, int remotePort)Setup SSH tunnel(Local Port Forwarding) (localhost:port to remoteHost:remotePort)voidunsetLocalPortForwarding(int localPort)Remove SSH tunnel(Local Port Forwarding) from the specific local port
-
-
-
方法详细资料
-
newInstance
public static SshdClient newInstance(String sshServerHost, int sshServerPort, String userName, String password)
-
newInstance
public static SshdClient newInstance(String sshServerHost, String userName, String password)
-
newInstance
public static SshdClient newInstance(String sshServerHost, int sshServerPort, String userName, Path privateKeyPath)
-
newInstance
public static SshdClient newInstance(String sshServerHost, String userName, Path privateKeyPath)
-
connect
public boolean connect()
从接口复制的说明:ConnectSSHConnect with SSH Server- 指定者:
connect在接口中ConnectSSH- 返回:
-
disconnect
public void disconnect()
从接口复制的说明:ConnectSSHDisconnect with SSH Server- 指定者:
disconnect在接口中ConnectSSH
-
setLocalPortForwarding
public void setLocalPortForwarding(int localPort, String remoteHost, int remotePort)从接口复制的说明:HasSshTunnelSetup SSH tunnel(Local Port Forwarding) (localhost:port to remoteHost:remotePort)- 指定者:
setLocalPortForwarding在接口中HasSshTunnel
-
unsetLocalPortForwarding
public void unsetLocalPortForwarding(int localPort)
从接口复制的说明:HasSshTunnelRemove SSH tunnel(Local Port Forwarding) from the specific local port- 指定者:
unsetLocalPortForwarding在接口中HasSshTunnel
-
executeCommand
public String executeCommand(String command)
从接口复制的说明:HasSshExecRemote execute command or commands
Single command like: pwd
Multiple commands like: cd..; pwd; ls -al;
Open a new channel for each invoke- 指定者:
executeCommand在接口中HasSshExec- 返回:
-
-