com.mindbright.ssh
Class SSHClient
java.lang.Object
com.mindbright.ssh.SSH
com.mindbright.ssh.SSHClient
- Direct Known Subclasses:
- SSHInteractiveClient
- public class SSHClient
- extends SSH
This class contains the main functionality for setting up a connection to a
ssh-server. It can be used both to implement a "full" ssh-client, or it can
be used to fire off a single command on the server (both in a background
thread and in the current-/foreground-thread). A set of properties can be
used to control different aspects of the connection. These are fetched from
an object implementing the SSHClientUser
-interface. The
authentication can be done in different ways, all which is handled through an
object implementing the SSHAuthenticator
-interface. The
console-output of the SSHClient
is (optionally) handled through
an object implementing the SSHConsole
-interface.
A class realizing a full interactive ssh-client is
SSHInteractiveClient
.
- Version:
- 0.96, 26/11/98
- Author:
- Mats Andersson
- See Also:
SSHAuthenticator
,
SSHClientUser
,
SSHConsole
Fields inherited from class com.mindbright.ssh.SSH |
AUTH_CRYPTOCARD, AUTH_DEFAULT, AUTH_HOSTBASED, AUTH_KBDINTERACT, AUTH_KERBEROS, AUTH_NOTSUPPORTED, AUTH_PASSWORD, AUTH_PUBLICKEY, AUTH_RHOSTS, AUTH_RHOSTS_RSA, AUTH_SDI, AUTH_TIS, authTypeDesc, CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DEFAULT, CIPHER_DES, CIPHER_IDEA, CIPHER_NONE, CIPHER_NOTSUPPORTED, CIPHER_RC4, CIPHER_RESERVED, CIPHER_TSS, cipherClasses, cipherType, CMSG_ACM_ACCESS_DENIED, CMSG_ACM_NEW_PIN, CMSG_ACM_NEW_PIN_ACCEPTED, CMSG_ACM_NEW_PIN_REJECTED, CMSG_ACM_NEW_PIN_REQUIRED, CMSG_ACM_NEXT_CODE, CMSG_ACM_NEXT_CODE_REQUIRED, CMSG_ACM_OK, CMSG_AGENT_REQUEST_FORWARDING, CMSG_AUTH_PASSWORD, CMSG_AUTH_RHOSTS, CMSG_AUTH_RHOSTS_RSA, CMSG_AUTH_RSA, CMSG_AUTH_RSA_RESPONSE, CMSG_AUTH_SDI, CMSG_AUTH_TIS, CMSG_AUTH_TIS_RESPONSE, CMSG_EOF, CMSG_EXEC_CMD, CMSG_EXEC_SHELL, CMSG_EXIT_CONFIRMATION, CMSG_MAX_PACKET_SIZE, CMSG_PORT_FORWARD_REQUEST, CMSG_REQUEST_COMPRESSION, CMSG_REQUEST_PTY, CMSG_SESSION_KEY, CMSG_STDIN_DATA, CMSG_USER, CMSG_WINDOW_SIZE, CMSG_X11_REQUEST_FORWARDING, CONNECT_CHAN_NUM, CVS_DATE, CVS_NAME, DEBUG, DEBUGMORE, DEFAULTPORT, HOST_KEY_LENGTH, IDX_CIPHER_CLASS, IDX_CIPHER_NAME, isAnSSHClient, KNOWN_HOSTS_FILE, LISTEN_CHAN_NUM, MAIN_CHAN_NUM, MSG_ANY, MSG_CHANNEL_CLOSE, MSG_CHANNEL_CLOSE_CONFIRMATION, MSG_CHANNEL_DATA, MSG_CHANNEL_INPUT_EOF, MSG_CHANNEL_OPEN_CONFIRMATION, MSG_CHANNEL_OPEN_FAILURE, MSG_CHANNEL_OUTPUT_CLOSED, MSG_DEBUG, MSG_DISCONNECT, MSG_IGNORE, MSG_NONE, MSG_PORT_OPEN, PASS_KERBEROS_TGT, protocolFlags, PROTOFLAG_HOST_IN_FWD_OPEN, PROTOFLAG_SCREEN_NUMBER, PROXY_HTTP, PROXY_NONE, PROXY_NOTSUPPORTED, PROXY_SOCKS4, PROXY_SOCKS5_DNS, PROXY_SOCKS5_IP, randomSeed, rcvCipher, rcvComp, secureRandom, SERVER_KEY_LENGTH, SESSION_KEY_LENGTH, sessionId, sessionKey, SMSG_AGENT_OPEN, SMSG_AUTH_RSA_CHALLENGE, SMSG_AUTH_TIS_CHALLENGE, SMSG_EXITSTATUS, SMSG_FAILURE, SMSG_PUBLIC_KEY, SMSG_STDERR_DATA, SMSG_STDOUT_DATA, SMSG_SUCCESS, SMSG_X11_OPEN, sndCipher, sndComp, SRV_HOSTKEY_CHANGED, SRV_HOSTKEY_KNOWN, SRV_HOSTKEY_NEW, srvCookie, srvHostKey, srvServerKey, SSH_VER_MAJOR, SSH_VER_MINOR, supportedAuthTypes, supportedCiphers, TTY_OP_END, TTY_OP_ISPEED, TTY_OP_OSPEED, UNKNOWN_CHAN_NUM, VER_MINDTERM, VER_MINDTUNL |
Method Summary |
void |
addLocalPortForward(int localPort,
java.lang.String remoteHost,
int remotePort,
java.lang.String plugin)
|
void |
addLocalPortForward(java.lang.String localHost,
int localPort,
java.lang.String remoteHost,
int remotePort,
java.lang.String plugin)
|
int |
addRef()
|
void |
addRemotePortForward(java.lang.String remoteHost,
int remotePort,
java.lang.String localHost,
int localPort,
java.lang.String plugin)
|
void |
boot(boolean haveCnxWatch,
java.net.Socket tpSocket)
|
void |
bootSSH(boolean haveCnxWatch)
|
void |
bootSSH(boolean haveCnxWatch,
boolean releaseConnection)
|
void |
clearAllForwards()
|
void |
delLocalPortForward(java.lang.String localHost,
int port)
|
int |
delRef()
|
void |
delRemotePortForward(java.lang.String plugin)
|
void |
delRemotePortForward(java.lang.String remoteHost,
int port)
|
protected void |
disconnect(boolean graceful)
|
void |
doSingleCommand(java.lang.String commandLine,
boolean background,
long msTimeout)
|
void |
forcedDisconnect()
|
long |
getConnectTimeout()
|
SSHConsole |
getConsole()
|
long |
getHelloTimeout()
|
java.net.InetAddress |
getLocalAddr()
|
java.net.InetAddress |
getServerAddr()
|
java.net.InetAddress |
getServerRealAddr()
|
java.lang.String |
getServerVersion()
|
boolean |
isConnected()
|
boolean |
isOpened()
|
void |
setConsole(SSHConsole console)
|
void |
setLocalAddr(java.lang.String addr)
|
void |
setServerRealAddr(java.net.InetAddress realAddr)
|
void |
startExitMonitor()
|
void |
startExitMonitor(long msTimeout)
|
void |
waitForExit(long msTimeout)
|
Methods inherited from class com.mindbright.ssh.SSH |
getAltAuthName, getAuthName, getAuthType, getAuthTypes, getCipherName, getCipherType, getProxyType, getProxyTypes, getVersionId, haveSecureRandom, initCipher, initClientCipher, initSeedGenerator, initServerCipher, isAuthTypeSupported, isCipherSupported, isProtocolFlagSet, log, logDebug, logExtra, logIgnore, randomSeed, secureRandom |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
myThread
protected java.lang.Thread myThread
keepAliveThread
protected com.mindbright.ssh.SSHClient.KeepAliveThread keepAliveThread
rand
protected SecureRandomAndPad rand
serverAddr
protected java.net.InetAddress serverAddr
serverRealAddr
protected java.net.InetAddress serverRealAddr
localAddr
protected java.net.InetAddress localAddr
srvVersionStr
protected java.lang.String srvVersionStr
srvVersionMajor
protected int srvVersionMajor
srvVersionMinor
protected int srvVersionMinor
localForwards
protected java.util.Vector localForwards
remoteForwards
protected java.util.Vector remoteForwards
commandLine
protected java.lang.String commandLine
controller
protected SSHChannelController controller
console
protected SSHConsole console
authenticator
protected SSHAuthenticator authenticator
user
protected SSHClientUser user
interactor
protected SSHInteractor interactor
sshSocket
protected java.net.Socket sshSocket
sshIn
protected java.io.BufferedInputStream sshIn
sshOut
protected java.io.BufferedOutputStream sshOut
gracefulExit
protected boolean gracefulExit
isConnected
protected boolean isConnected
isOpened
protected boolean isOpened
refCount
protected int refCount
havePORTFtp
protected boolean havePORTFtp
firstFTPPort
protected int firstFTPPort
activateTunnels
protected boolean activateTunnels
SSHClient
public SSHClient(SSHAuthenticator authenticator,
SSHClientUser user)
setConsole
public void setConsole(SSHConsole console)
getConsole
public SSHConsole getConsole()
getServerAddr
public java.net.InetAddress getServerAddr()
getServerRealAddr
public java.net.InetAddress getServerRealAddr()
setServerRealAddr
public void setServerRealAddr(java.net.InetAddress realAddr)
getLocalAddr
public java.net.InetAddress getLocalAddr()
setLocalAddr
public void setLocalAddr(java.lang.String addr)
throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
getServerVersion
public java.lang.String getServerVersion()
addLocalPortForward
public void addLocalPortForward(int localPort,
java.lang.String remoteHost,
int remotePort,
java.lang.String plugin)
throws java.io.IOException
- Throws:
java.io.IOException
addLocalPortForward
public void addLocalPortForward(java.lang.String localHost,
int localPort,
java.lang.String remoteHost,
int remotePort,
java.lang.String plugin)
throws java.io.IOException
- Throws:
java.io.IOException
delLocalPortForward
public void delLocalPortForward(java.lang.String localHost,
int port)
addRemotePortForward
public void addRemotePortForward(java.lang.String remoteHost,
int remotePort,
java.lang.String localHost,
int localPort,
java.lang.String plugin)
delRemotePortForward
public void delRemotePortForward(java.lang.String remoteHost,
int port)
delRemotePortForward
public void delRemotePortForward(java.lang.String plugin)
clearAllForwards
public void clearAllForwards()
startExitMonitor
public void startExitMonitor()
startExitMonitor
public void startExitMonitor(long msTimeout)
addRef
public int addRef()
forcedDisconnect
public void forcedDisconnect()
delRef
public int delRef()
waitForExit
public void waitForExit(long msTimeout)
doSingleCommand
public void doSingleCommand(java.lang.String commandLine,
boolean background,
long msTimeout)
throws java.io.IOException
- Throws:
java.io.IOException
getConnectTimeout
public long getConnectTimeout()
getHelloTimeout
public long getHelloTimeout()
bootSSH
public void bootSSH(boolean haveCnxWatch)
throws java.io.IOException
- Throws:
java.io.IOException
bootSSH
public void bootSSH(boolean haveCnxWatch,
boolean releaseConnection)
throws java.io.IOException
- Throws:
java.io.IOException
boot
public void boot(boolean haveCnxWatch,
java.net.Socket tpSocket)
throws java.io.IOException
- Throws:
java.io.IOException
disconnect
protected void disconnect(boolean graceful)
isOpened
public boolean isOpened()
isConnected
public boolean isConnected()