java.lang.Object
mindbright.ssh.SSH
mindbright.ssh.SSHClient
- Direct Known Subclasses:
- SSHInteractiveClient, SSHTunnelingClient
- 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 singe 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. The SSHClient-class
is also used transparently from the SSHSocket- and SSHServerSocket-
classes (through the SSHSocketFactory- and SSHSocketImpl-classes).
- Version:
- 0.96, 26/11/98
| Fields inherited from class mindbright.ssh.SSH |
AUTH_DEFAULT, AUTH_KERBEROS, AUTH_NOTSUPPORTED, AUTH_PASSWORD, AUTH_RHOSTS, AUTH_RHOSTS_RSA, AUTH_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, defaultProxyPorts, 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, NETSCAPE_SECURITY_MODEL, 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, proxyTypes, rcvCipher, 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, 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, VER_SSHPKG |
|
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(int remotePort,
java.lang.String localHost,
int localPort,
java.lang.String plugin)
|
(package private) void |
authenticateUser(java.lang.String userName)
|
void |
bootSSH(boolean haveCnxWatch)
|
void |
clearAllForwards()
|
void |
delLocalPortForward(java.lang.String localHost,
int port)
|
int |
delRef()
|
void |
delRemotePortForward(int port)
|
void |
delRemotePortForward(java.lang.String plugin)
|
protected void |
disconnect(boolean graceful)
|
(package private) void |
doPasswdAuth(java.lang.String userName)
|
(package private) void |
doRhostsAuth(java.lang.String userName)
|
(package private) void |
doRSAAuth(boolean rhosts,
java.lang.String userName)
|
(package private) void |
doSDIAuth(java.lang.String userName)
|
void |
doSingleCommand(java.lang.String commandLine,
boolean background,
long msTimeout)
|
(package private) void |
doTISAuth(java.lang.String userName)
|
void |
forcedDisconnect()
|
(package private) void |
generateSessionKey()
|
SSHConsole |
getConsole()
|
java.net.InetAddress |
getLocalAddr()
|
java.net.InetAddress |
getServerAddr()
|
java.net.InetAddress |
getServerRealAddr()
|
java.lang.String |
getServerVersion()
|
(package private) void |
initiatePlugins()
|
(package private) void |
initiateSession()
|
(package private) void |
initiateTunnels()
|
boolean |
isConnected()
|
boolean |
isOpened()
|
(package private) boolean |
isSuccess()
|
(package private) void |
negotiateVersion()
|
(package private) void |
receiveServerData()
|
(package private) void |
requestCommand(java.lang.String command)
|
(package private) void |
requestCompression(int level)
|
(package private) void |
requestLocalPortForward(java.lang.String localHost,
int localPort,
java.lang.String remoteHost,
int remotePort,
java.lang.String plugin)
|
(package private) void |
requestMaxPacketSz(int sz)
|
(package private) void |
requestPTY()
|
(package private) void |
requestRemotePortForward(int remotePort,
java.lang.String localHost,
int localPort,
java.lang.String plugin)
|
(package private) void |
requestShell()
|
(package private) void |
requestX11Forward()
|
(package private) void |
rsaChallengeResponse(mindbright.security.RSAPrivateKey privKey,
java.math.BigInteger challenge)
|
(package private) void |
sendSessionKey(int cipherType)
|
(package private) void |
setAliveInterval(int i)
|
void |
setConsole(SSHConsole console)
|
(package private) void |
setInteractive()
|
void |
setLocalAddr(java.lang.String addr)
|
void |
setServerRealAddr(java.net.InetAddress realAddr)
|
(package private) void |
signalWindowChanged(int rows,
int cols,
int vpixels,
int hpixels)
|
void |
startExitMonitor()
|
void |
startExitMonitor(long msTimeout)
|
void |
stdinWriteChar(char c)
|
void |
stdinWriteString(byte[] str)
|
void |
stdinWriteString(byte[] str,
int off,
int len)
|
void |
stdinWriteString(java.lang.String str)
|
void |
waitForExit(long msTimeout)
|
| Methods inherited from class mindbright.ssh.SSH |
cntListSize, generateKeyFiles, generateRSAKeyPair, generateSessionId, getAuthName, getAuthType, getAuthTypeList, getAuthTypes, getCipherName, getCiphers, getCipherType, getProxyType, getProxyTypes, getVersionId, initCipher, initClientCipher, initSeedGenerator, initServerCipher, isAuthTypeSupported, isCipherSupported, isProtocolFlagSet, listSupportedAuthTypes, listSupportedCiphers, listSupportedProxyTypes, log, logDebug, logExtra, logIgnore, 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 SSHClient.KeepAliveThread keepAliveThread
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
usedOTP
boolean usedOTP
refCount
protected int refCount
havePORTFtp
protected boolean havePORTFtp
firstFTPPort
protected int firstFTPPort
activateTunnels
protected boolean activateTunnels
CANNOT_CHOOSE_PIN
private static final int CANNOT_CHOOSE_PIN
- See Also:
- Constant Field Values
USER_SELECTABLE
private static final int USER_SELECTABLE
- See Also:
- Constant Field Values
MUST_CHOOSE_PIN
private static final int MUST_CHOOSE_PIN
- See Also:
- Constant Field Values
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
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
addLocalPortForward
public void addLocalPortForward(java.lang.String localHost,
int localPort,
java.lang.String remoteHost,
int remotePort,
java.lang.String plugin)
throws java.io.IOException
delLocalPortForward
public void delLocalPortForward(java.lang.String localHost,
int port)
addRemotePortForward
public void addRemotePortForward(int remotePort,
java.lang.String localHost,
int localPort,
java.lang.String plugin)
delRemotePortForward
public void delRemotePortForward(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
bootSSH
public void bootSSH(boolean haveCnxWatch)
throws java.io.IOException
disconnect
protected void disconnect(boolean graceful)
negotiateVersion
void negotiateVersion()
throws java.io.IOException
receiveServerData
void receiveServerData()
throws java.io.IOException
generateSessionKey
void generateSessionKey()
sendSessionKey
void sendSessionKey(int cipherType)
throws java.io.IOException
authenticateUser
void authenticateUser(java.lang.String userName)
throws java.io.IOException
doPasswdAuth
void doPasswdAuth(java.lang.String userName)
throws java.io.IOException
doRhostsAuth
void doRhostsAuth(java.lang.String userName)
throws java.io.IOException
doTISAuth
void doTISAuth(java.lang.String userName)
throws java.io.IOException
doRSAAuth
void doRSAAuth(boolean rhosts,
java.lang.String userName)
throws java.io.IOException
doSDIAuth
void doSDIAuth(java.lang.String userName)
throws java.io.IOException
rsaChallengeResponse
void rsaChallengeResponse(mindbright.security.RSAPrivateKey privKey,
java.math.BigInteger challenge)
throws java.io.IOException
initiateSession
void initiateSession()
throws java.io.IOException
initiatePlugins
void initiatePlugins()
initiateTunnels
void initiateTunnels()
throws java.io.IOException
requestCompression
void requestCompression(int level)
throws java.io.IOException
requestMaxPacketSz
void requestMaxPacketSz(int sz)
throws java.io.IOException
requestX11Forward
void requestX11Forward()
throws java.io.IOException
requestPTY
void requestPTY()
throws java.io.IOException
requestLocalPortForward
void requestLocalPortForward(java.lang.String localHost,
int localPort,
java.lang.String remoteHost,
int remotePort,
java.lang.String plugin)
throws java.io.IOException
requestRemotePortForward
void requestRemotePortForward(int remotePort,
java.lang.String localHost,
int localPort,
java.lang.String plugin)
throws java.io.IOException
requestCommand
void requestCommand(java.lang.String command)
throws java.io.IOException
requestShell
void requestShell()
throws java.io.IOException
isSuccess
boolean isSuccess()
throws java.io.IOException
setInteractive
void setInteractive()
setAliveInterval
void setAliveInterval(int i)
isOpened
public boolean isOpened()
isConnected
public boolean isConnected()
stdinWriteChar
public void stdinWriteChar(char c)
throws java.io.IOException
stdinWriteString
public void stdinWriteString(java.lang.String str)
throws java.io.IOException
stdinWriteString
public void stdinWriteString(byte[] str)
throws java.io.IOException
stdinWriteString
public void stdinWriteString(byte[] str,
int off,
int len)
throws java.io.IOException
signalWindowChanged
void signalWindowChanged(int rows,
int cols,
int vpixels,
int hpixels)