Package com.jcraft.jsch
Class Session
- java.lang.Object
-
- com.jcraft.jsch.Session
-
- All Implemented Interfaces:
java.lang.Runnable
public class Session extends java.lang.Object implements java.lang.Runnable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classSession.Forwardingprivate classSession.GlobalRequestReply
-
Field Summary
Fields Modifier and Type Field Description (package private) booleanagent_forwarding(package private) intauth_failures(package private) Bufferbuf(package private) static intbuffer_marginprivate Cipherc2scipherprivate intc2scipher_sizeprivate MACc2smac(package private) int[]compress_lenprivate java.util.Hashtableconfigprivate java.lang.ThreadconnectThreadprotected booleandaemon_threadprivate Compressiondeflaterprivate byte[]Ec2sprivate byte[]Es2cprivate Session.GlobalRequestReplygrr(package private) java.lang.String[]guess(package private) java.lang.Stringhostprivate HostKeyhostkeyprivate java.lang.StringhostKeyAliasprivate HostKeyRepositoryhostkeyRepositoryprivate byte[]I_Cprivate byte[]I_Sprivate IdentityRepositoryidentityRepository(package private) java.io.InputStreaminprivate booleanin_kexprivate booleanin_promptprivate Compressioninflaterprivate IOioprivate booleanisAuthedprivate booleanisConnectedprivate byte[]IVc2sprivate byte[]IVs2c(package private) JSchjschprivate byte[]K_Sprivate static byte[]keepalivemsgprivate longkex_start_timeprivate java.lang.Objectlockprivate byte[]MACc2sprivate byte[]MACs2c(package private) intmax_auth_triesprivate static byte[]nomoresessions(package private) java.lang.Stringorg_host(package private) java.io.OutputStreamout(package private) Packetpacketprivate static intPACKET_MAX_SIZE(package private) byte[]password(package private) intportprivate Proxyproxy(package private) static Randomrandomprivate Ciphers2ccipherprivate ints2ccipher_sizeprivate MACs2cmacprivate byte[]s2cmac_result1private byte[]s2cmac_result2private intseqiprivate intseqoprivate intserverAliveCountMaxprivate intserverAliveIntervalprivate byte[]session_idprivate java.net.Socketsocket(package private) SocketFactorysocket_factory(package private) static intSSH_MSG_CHANNEL_CLOSE(package private) static intSSH_MSG_CHANNEL_DATA(package private) static intSSH_MSG_CHANNEL_EOF(package private) static intSSH_MSG_CHANNEL_EXTENDED_DATA(package private) static intSSH_MSG_CHANNEL_FAILURE(package private) static intSSH_MSG_CHANNEL_OPEN(package private) static intSSH_MSG_CHANNEL_OPEN_CONFIRMATION(package private) static intSSH_MSG_CHANNEL_OPEN_FAILURE(package private) static intSSH_MSG_CHANNEL_REQUEST(package private) static intSSH_MSG_CHANNEL_SUCCESS(package private) static intSSH_MSG_CHANNEL_WINDOW_ADJUST(package private) static intSSH_MSG_DEBUG(package private) static intSSH_MSG_DISCONNECT(package private) static intSSH_MSG_GLOBAL_REQUEST(package private) static intSSH_MSG_IGNORE(package private) static intSSH_MSG_KEX_DH_GEX_GROUP(package private) static intSSH_MSG_KEX_DH_GEX_INIT(package private) static intSSH_MSG_KEX_DH_GEX_REPLY(package private) static intSSH_MSG_KEX_DH_GEX_REQUEST(package private) static intSSH_MSG_KEXDH_INIT(package private) static intSSH_MSG_KEXDH_REPLY(package private) static intSSH_MSG_KEXINIT(package private) static intSSH_MSG_NEWKEYS(package private) static intSSH_MSG_REQUEST_FAILURE(package private) static intSSH_MSG_REQUEST_SUCCESS(package private) static intSSH_MSG_SERVICE_ACCEPT(package private) static intSSH_MSG_SERVICE_REQUEST(package private) static intSSH_MSG_UNIMPLEMENTED(package private) java.lang.Runnablethreadprivate inttimeout(package private) int[]uncompress_lenprivate UserInfouserinfo(package private) java.lang.Stringusernameprivate byte[]V_Cprivate byte[]V_S(package private) booleanx11_forwarding
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private int_setPortForwardingR(java.lang.String bind_address, int rport)private void_write(Packet packet)(package private) voidaddChannel(Channel channel)private voidapplyConfig()private voidapplyConfigChannel(ChannelSession channel)(package private) static booleancheckCipher(java.lang.String cipher)private java.lang.String[]checkCiphers(java.lang.String ciphers)private voidcheckConfig(ConfigRepository.Config config, java.lang.String key)private voidcheckHost(java.lang.String chost, int port, KeyExchange kex)(package private) static booleancheckKex(Session s, java.lang.String kex)private java.lang.String[]checkKexes(java.lang.String kexes)private java.lang.String[]checkSignatures(java.lang.String sigs)voidconnect()voidconnect(int connectTimeout)voiddelPortForwardingL(int lport)Cancels the local port forwarding assigned at local TCP portlporton loopback interface.voiddelPortForwardingL(java.lang.String bind_address, int lport)Cancels the local port forwarding assigned at local TCP portlportonbind_addressinterface.voiddelPortForwardingR(int rport)Cancels the remote port forwarding assigned at remote TCP portrport.voiddelPortForwardingR(java.lang.String bind_address, int rport)Cancels the remote port forwarding assigned at remote TCP portrportbound on the interface atbind_address.voiddisconnect()voidencode(Packet packet)private byte[]expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, int required_length)java.lang.StringgetClientVersion()java.lang.StringgetConfig(java.lang.String key)java.lang.StringgetHost()HostKeygetHostKey()java.lang.StringgetHostKeyAlias()HostKeyRepositorygetHostKeyRepository()Gets the hostkeyRepository.(package private) IdentityRepositorygetIdentityRepository()Gets the identityRepository.intgetPort()java.lang.String[]getPortForwardingL()Lists the registered local port forwarding.java.lang.String[]getPortForwardingR()Lists the registered remote port forwarding.intgetServerAliveCountMax()Returns setting for the threshold to send keep-alive messages.intgetServerAliveInterval()Returns setting for the interval to send a keep-alive message.java.lang.StringgetServerVersion()(package private) byte[]getSessionId()ChannelgetStreamForwarder(java.lang.String host, int port)Instantiates an instance of stream-forwarder tohost:port.intgetTimeout()UserInfogetUserInfo()java.lang.StringgetUserName()private voidinitDeflater(java.lang.String method)private voidinitInflater(java.lang.String method)booleanisConnected()voidnoMoreSessionChannels()ChannelopenChannel(java.lang.String type)private Session.ForwardingparseForwarding(java.lang.String conf)The given argument may be "[bind_address:]port:host:hostport" or "[bind_address:]port host:hostport", which is from LocalForward command of ~/.ssh/config .Bufferread(Buffer buf)private KeyExchangereceive_kexinit(Buffer buf)private voidreceive_newkeys(Buffer buf, KeyExchange kex)voidrekey()private voidrequestPortForwarding()voidrun()private voidsend_kexinit()private voidsend_newkeys()voidsendIgnore()voidsendKeepAliveMsg()voidsetClientVersion(java.lang.String cv)voidsetConfig(java.lang.String key, java.lang.String value)voidsetConfig(java.util.Hashtable newconf)voidsetConfig(java.util.Properties newconf)voidsetDaemonThread(boolean enable)voidsetHost(java.lang.String host)voidsetHostKeyAlias(java.lang.String hostKeyAlias)voidsetHostKeyRepository(HostKeyRepository hostkeyRepository)Sets the hostkeyRepository, which will be referred in checking host keys.voidsetIdentityRepository(IdentityRepository identityRepository)Sets the identityRepository, which will be referred in the public key authentication.voidsetInputStream(java.io.InputStream in)voidsetOutputStream(java.io.OutputStream out)voidsetPassword(byte[] password)voidsetPassword(java.lang.String password)voidsetPort(int port)intsetPortForwardingL(int lport, java.lang.String host, int rport)Registers the local port forwarding for loop-back interface.intsetPortForwardingL(java.lang.String conf)Registers the local port forwarding.intsetPortForwardingL(java.lang.String bind_address, int lport, java.lang.String host, int rport)Registers the local port forwarding.intsetPortForwardingL(java.lang.String bind_address, int lport, java.lang.String host, int rport, ServerSocketFactory ssf)Registers the local port forwarding.intsetPortForwardingL(java.lang.String bind_address, int lport, java.lang.String host, int rport, ServerSocketFactory ssf, int connectTimeout)Registers the local port forwarding.voidsetPortForwardingR(int rport, java.lang.String daemon)Registers the remote port forwarding for the loopback interface of the remote.voidsetPortForwardingR(int rport, java.lang.String host, int lport)Registers the remote port forwarding for the loopback interface of the remote.voidsetPortForwardingR(int rport, java.lang.String host, int lport, SocketFactory sf)Registers the remote port forwarding for the loopback interface of the remote.voidsetPortForwardingR(int rport, java.lang.String daemon, java.lang.Object[] arg)Registers the remote port forwarding for the loopback interface of the remote.intsetPortForwardingR(java.lang.String conf)Registers the remote port forwarding.voidsetPortForwardingR(java.lang.String bind_address, int rport, java.lang.String host, int lport)Registers the remote port forwarding.voidsetPortForwardingR(java.lang.String bind_address, int rport, java.lang.String host, int lport, SocketFactory sf)Registers the remote port forwarding.voidsetPortForwardingR(java.lang.String bind_address, int rport, java.lang.String daemon, java.lang.Object[] arg)Registers the remote port forwarding.voidsetProxy(Proxy proxy)voidsetServerAliveCountMax(int count)Sets the number of keep-alive messages which may be sent without receiving any messages back from the server.voidsetServerAliveInterval(int interval)Sets the interval to send a keep-alive message.voidsetSocketFactory(SocketFactory sfactory)voidsetTimeout(int timeout)voidsetUserInfo(UserInfo userinfo)(package private) voidsetUserName(java.lang.String username)voidsetX11Cookie(java.lang.String cookie)voidsetX11Host(java.lang.String host)voidsetX11Port(int port)private voidstart_discard(Buffer buf, Cipher cipher, MAC mac, int packet_length, int discard)private voidupdateKeys(KeyExchange kex)voidwrite(Packet packet)(package private) voidwrite(Packet packet, Channel c, int length)
-
-
-
Field Detail
-
SSH_MSG_DISCONNECT
static final int SSH_MSG_DISCONNECT
- See Also:
- Constant Field Values
-
SSH_MSG_IGNORE
static final int SSH_MSG_IGNORE
- See Also:
- Constant Field Values
-
SSH_MSG_UNIMPLEMENTED
static final int SSH_MSG_UNIMPLEMENTED
- See Also:
- Constant Field Values
-
SSH_MSG_DEBUG
static final int SSH_MSG_DEBUG
- See Also:
- Constant Field Values
-
SSH_MSG_SERVICE_REQUEST
static final int SSH_MSG_SERVICE_REQUEST
- See Also:
- Constant Field Values
-
SSH_MSG_SERVICE_ACCEPT
static final int SSH_MSG_SERVICE_ACCEPT
- See Also:
- Constant Field Values
-
SSH_MSG_KEXINIT
static final int SSH_MSG_KEXINIT
- See Also:
- Constant Field Values
-
SSH_MSG_NEWKEYS
static final int SSH_MSG_NEWKEYS
- See Also:
- Constant Field Values
-
SSH_MSG_KEXDH_INIT
static final int SSH_MSG_KEXDH_INIT
- See Also:
- Constant Field Values
-
SSH_MSG_KEXDH_REPLY
static final int SSH_MSG_KEXDH_REPLY
- See Also:
- Constant Field Values
-
SSH_MSG_KEX_DH_GEX_GROUP
static final int SSH_MSG_KEX_DH_GEX_GROUP
- See Also:
- Constant Field Values
-
SSH_MSG_KEX_DH_GEX_INIT
static final int SSH_MSG_KEX_DH_GEX_INIT
- See Also:
- Constant Field Values
-
SSH_MSG_KEX_DH_GEX_REPLY
static final int SSH_MSG_KEX_DH_GEX_REPLY
- See Also:
- Constant Field Values
-
SSH_MSG_KEX_DH_GEX_REQUEST
static final int SSH_MSG_KEX_DH_GEX_REQUEST
- See Also:
- Constant Field Values
-
SSH_MSG_GLOBAL_REQUEST
static final int SSH_MSG_GLOBAL_REQUEST
- See Also:
- Constant Field Values
-
SSH_MSG_REQUEST_SUCCESS
static final int SSH_MSG_REQUEST_SUCCESS
- See Also:
- Constant Field Values
-
SSH_MSG_REQUEST_FAILURE
static final int SSH_MSG_REQUEST_FAILURE
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_OPEN
static final int SSH_MSG_CHANNEL_OPEN
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_OPEN_CONFIRMATION
static final int SSH_MSG_CHANNEL_OPEN_CONFIRMATION
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_OPEN_FAILURE
static final int SSH_MSG_CHANNEL_OPEN_FAILURE
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_WINDOW_ADJUST
static final int SSH_MSG_CHANNEL_WINDOW_ADJUST
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_DATA
static final int SSH_MSG_CHANNEL_DATA
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_EXTENDED_DATA
static final int SSH_MSG_CHANNEL_EXTENDED_DATA
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_EOF
static final int SSH_MSG_CHANNEL_EOF
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_CLOSE
static final int SSH_MSG_CHANNEL_CLOSE
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_REQUEST
static final int SSH_MSG_CHANNEL_REQUEST
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_SUCCESS
static final int SSH_MSG_CHANNEL_SUCCESS
- See Also:
- Constant Field Values
-
SSH_MSG_CHANNEL_FAILURE
static final int SSH_MSG_CHANNEL_FAILURE
- See Also:
- Constant Field Values
-
PACKET_MAX_SIZE
private static final int PACKET_MAX_SIZE
- See Also:
- Constant Field Values
-
V_S
private byte[] V_S
-
V_C
private byte[] V_C
-
I_C
private byte[] I_C
-
I_S
private byte[] I_S
-
K_S
private byte[] K_S
-
session_id
private byte[] session_id
-
IVc2s
private byte[] IVc2s
-
IVs2c
private byte[] IVs2c
-
Ec2s
private byte[] Ec2s
-
Es2c
private byte[] Es2c
-
MACc2s
private byte[] MACc2s
-
MACs2c
private byte[] MACs2c
-
seqi
private int seqi
-
seqo
private int seqo
-
guess
java.lang.String[] guess
-
s2ccipher
private Cipher s2ccipher
-
c2scipher
private Cipher c2scipher
-
s2cmac
private MAC s2cmac
-
c2smac
private MAC c2smac
-
s2cmac_result1
private byte[] s2cmac_result1
-
s2cmac_result2
private byte[] s2cmac_result2
-
deflater
private Compression deflater
-
inflater
private Compression inflater
-
io
private IO io
-
socket
private java.net.Socket socket
-
timeout
private int timeout
-
isConnected
private volatile boolean isConnected
-
isAuthed
private boolean isAuthed
-
connectThread
private java.lang.Thread connectThread
-
lock
private java.lang.Object lock
-
x11_forwarding
boolean x11_forwarding
-
agent_forwarding
boolean agent_forwarding
-
in
java.io.InputStream in
-
out
java.io.OutputStream out
-
random
static Random random
-
buf
Buffer buf
-
packet
Packet packet
-
socket_factory
SocketFactory socket_factory
-
buffer_margin
static final int buffer_margin
- See Also:
- Constant Field Values
-
config
private java.util.Hashtable config
-
proxy
private Proxy proxy
-
userinfo
private UserInfo userinfo
-
hostKeyAlias
private java.lang.String hostKeyAlias
-
serverAliveInterval
private int serverAliveInterval
-
serverAliveCountMax
private int serverAliveCountMax
-
identityRepository
private IdentityRepository identityRepository
-
hostkeyRepository
private HostKeyRepository hostkeyRepository
-
daemon_thread
protected boolean daemon_thread
-
kex_start_time
private long kex_start_time
-
max_auth_tries
int max_auth_tries
-
auth_failures
int auth_failures
-
host
java.lang.String host
-
org_host
java.lang.String org_host
-
port
int port
-
username
java.lang.String username
-
password
byte[] password
-
jsch
JSch jsch
-
in_kex
private volatile boolean in_kex
-
in_prompt
private volatile boolean in_prompt
-
uncompress_len
int[] uncompress_len
-
compress_len
int[] compress_len
-
s2ccipher_size
private int s2ccipher_size
-
c2scipher_size
private int c2scipher_size
-
thread
java.lang.Runnable thread
-
grr
private Session.GlobalRequestReply grr
-
keepalivemsg
private static final byte[] keepalivemsg
-
nomoresessions
private static final byte[] nomoresessions
-
hostkey
private HostKey hostkey
-
-
Constructor Detail
-
Session
Session(JSch jsch, java.lang.String username, java.lang.String host, int port) throws JSchException
- Throws:
JSchException
-
-
Method Detail
-
connect
public void connect() throws JSchException- Throws:
JSchException
-
connect
public void connect(int connectTimeout) throws JSchException- Throws:
JSchException
-
receive_kexinit
private KeyExchange receive_kexinit(Buffer buf) throws java.lang.Exception
- Throws:
java.lang.Exception
-
rekey
public void rekey() throws java.lang.Exception- Throws:
java.lang.Exception
-
send_kexinit
private void send_kexinit() throws java.lang.Exception- Throws:
java.lang.Exception
-
send_newkeys
private void send_newkeys() throws java.lang.Exception- Throws:
java.lang.Exception
-
checkHost
private void checkHost(java.lang.String chost, int port, KeyExchange kex) throws JSchException- Throws:
JSchException
-
openChannel
public Channel openChannel(java.lang.String type) throws JSchException
- Throws:
JSchException
-
encode
public void encode(Packet packet) throws java.lang.Exception
- Throws:
java.lang.Exception
-
start_discard
private void start_discard(Buffer buf, Cipher cipher, MAC mac, int packet_length, int discard) throws JSchException, java.io.IOException
- Throws:
JSchExceptionjava.io.IOException
-
getSessionId
byte[] getSessionId()
-
receive_newkeys
private void receive_newkeys(Buffer buf, KeyExchange kex) throws java.lang.Exception
- Throws:
java.lang.Exception
-
updateKeys
private void updateKeys(KeyExchange kex) throws java.lang.Exception
- Throws:
java.lang.Exception
-
expandKey
private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, int required_length) throws java.lang.Exception
- Throws:
java.lang.Exception
-
write
void write(Packet packet, Channel c, int length) throws java.lang.Exception
- Throws:
java.lang.Exception
-
write
public void write(Packet packet) throws java.lang.Exception
- Throws:
java.lang.Exception
-
_write
private void _write(Packet packet) throws java.lang.Exception
- Throws:
java.lang.Exception
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
disconnect
public void disconnect()
-
setPortForwardingL
public int setPortForwardingL(int lport, java.lang.String host, int rport) throws JSchExceptionRegisters the local port forwarding for loop-back interface. Iflportis0, the tcp port will be allocated.- Parameters:
lport- local port for local port forwardinghost- host address for local port forwardingrport- remote port number for local port forwarding- Returns:
- an allocated local TCP port number
- Throws:
JSchException- See Also:
setPortForwardingL(String bind_address, int lport, String host, int rport, ServerSocketFactory ssf, int connectTimeout)
-
setPortForwardingL
public int setPortForwardingL(java.lang.String bind_address, int lport, java.lang.String host, int rport) throws JSchExceptionRegisters the local port forwarding. Ifbind_addressis an empty string or '*', the port should be available from all interfaces. Ifbind_addressis"localhost"ornull, the listening port will be bound for local use only. Iflportis0, the tcp port will be allocated.- Parameters:
bind_address- bind address for local port forwardinglport- local port for local port forwardinghost- host address for local port forwardingrport- remote port number for local port forwarding- Returns:
- an allocated local TCP port number
- Throws:
JSchException- See Also:
setPortForwardingL(String bind_address, int lport, String host, int rport, ServerSocketFactory ssf, int connectTimeout)
-
setPortForwardingL
public int setPortForwardingL(java.lang.String bind_address, int lport, java.lang.String host, int rport, ServerSocketFactory ssf) throws JSchExceptionRegisters the local port forwarding. Ifbind_addressis an empty string or"*", the port should be available from all interfaces. Ifbind_addressis"localhost"ornull, the listening port will be bound for local use only. Iflportis0, the tcp port will be allocated.- Parameters:
bind_address- bind address for local port forwardinglport- local port for local port forwardinghost- host address for local port forwardingrport- remote port number for local port forwardingssf- socket factory- Returns:
- an allocated local TCP port number
- Throws:
JSchException- See Also:
setPortForwardingL(String bind_address, int lport, String host, int rport, ServerSocketFactory ssf, int connectTimeout)
-
setPortForwardingL
public int setPortForwardingL(java.lang.String bind_address, int lport, java.lang.String host, int rport, ServerSocketFactory ssf, int connectTimeout) throws JSchExceptionRegisters the local port forwarding. Ifbind_addressis an empty string or"*", the port should be available from all interfaces. Ifbind_addressis"localhost"ornull, the listening port will be bound for local use only. Iflportis0, the tcp port will be allocated.- Parameters:
bind_address- bind address for local port forwardinglport- local port for local port forwardinghost- host address for local port forwardingrport- remote port number for local port forwardingssf- socket factoryconnectTimeout- timeout for establishing port connection- Returns:
- an allocated local TCP port number
- Throws:
JSchException
-
delPortForwardingL
public void delPortForwardingL(int lport) throws JSchExceptionCancels the local port forwarding assigned at local TCP portlporton loopback interface.- Parameters:
lport- local TCP port- Throws:
JSchException
-
delPortForwardingL
public void delPortForwardingL(java.lang.String bind_address, int lport) throws JSchExceptionCancels the local port forwarding assigned at local TCP portlportonbind_addressinterface.- Parameters:
bind_address- bind_address of network interfaceslport- local TCP port- Throws:
JSchException
-
getPortForwardingL
public java.lang.String[] getPortForwardingL() throws JSchExceptionLists the registered local port forwarding.- Returns:
- a list of "lport:host:hostport"
- Throws:
JSchException
-
setPortForwardingR
public void setPortForwardingR(int rport, java.lang.String host, int lport) throws JSchExceptionRegisters the remote port forwarding for the loopback interface of the remote.- Parameters:
rport- remote porthost- host addresslport- local port- Throws:
JSchException- See Also:
setPortForwardingR(String bind_address, int rport, String host, int lport, SocketFactory sf)
-
setPortForwardingR
public void setPortForwardingR(java.lang.String bind_address, int rport, java.lang.String host, int lport) throws JSchExceptionRegisters the remote port forwarding. Ifbind_addressis an empty string or"*", the port should be available from all interfaces. Ifbind_addressis"localhost"or is not given, the listening port will be bound for local use only. Note that ifGatewayPortsis"no"on the remote,"localhost"is always used as a bind_address.- Parameters:
bind_address- bind addressrport- remote porthost- host addresslport- local port- Throws:
JSchException- See Also:
setPortForwardingR(String bind_address, int rport, String host, int lport, SocketFactory sf)
-
setPortForwardingR
public void setPortForwardingR(int rport, java.lang.String host, int lport, SocketFactory sf) throws JSchExceptionRegisters the remote port forwarding for the loopback interface of the remote.- Parameters:
rport- remote porthost- host addresslport- local portsf- socket factory- Throws:
JSchException- See Also:
setPortForwardingR(String bind_address, int rport, String host, int lport, SocketFactory sf)
-
setPortForwardingR
public void setPortForwardingR(java.lang.String bind_address, int rport, java.lang.String host, int lport, SocketFactory sf) throws JSchExceptionRegisters the remote port forwarding. Ifbind_addressis an empty string or"*", the port should be available from all interfaces. Ifbind_addressis"localhost"or is not given, the listening port will be bound for local use only. Note that ifGatewayPortsis"no"on the remote,"localhost"is always used as a bind_address. Ifrportis0, the TCP port will be allocated on the remote.- Parameters:
bind_address- bind addressrport- remote porthost- host addresslport- local portsf- socket factory- Throws:
JSchException
-
setPortForwardingR
public void setPortForwardingR(int rport, java.lang.String daemon) throws JSchExceptionRegisters the remote port forwarding for the loopback interface of the remote. The TCP connection torporton the remote will be forwarded to an instance of the classdaemon. The class specified bydaemonmust implementForwardedTCPIPDaemon.- Parameters:
rport- remote portdaemon- class name, which implements "ForwardedTCPIPDaemon"- Throws:
JSchException- See Also:
setPortForwardingR(String bind_address, int rport, String daemon, Object[] arg)
-
setPortForwardingR
public void setPortForwardingR(int rport, java.lang.String daemon, java.lang.Object[] arg) throws JSchExceptionRegisters the remote port forwarding for the loopback interface of the remote. The TCP connection torporton the remote will be forwarded to an instance of the classdaemonwith the argumentarg. The class specified bydaemonmust implementForwardedTCPIPDaemon.- Parameters:
rport- remote portdaemon- class name, which implements "ForwardedTCPIPDaemon"arg- arguments for "daemon"- Throws:
JSchException- See Also:
setPortForwardingR(String bind_address, int rport, String daemon, Object[] arg)
-
setPortForwardingR
public void setPortForwardingR(java.lang.String bind_address, int rport, java.lang.String daemon, java.lang.Object[] arg) throws JSchExceptionRegisters the remote port forwarding. Ifbind_addressis an empty string or"*", the port should be available from all interfaces. Ifbind_addressis"localhost"or is not given, the listening port will be bound for local use only. Note that ifGatewayPortsis"no"on the remote,"localhost"is always used as a bind_address. The TCP connection torporton the remote will be forwarded to an instance of the classdaemonwith the argumentarg. The class specified bydaemonmust implementForwardedTCPIPDaemon.- Parameters:
bind_address- bind addressrport- remote portdaemon- class name, which implements "ForwardedTCPIPDaemon"arg- arguments for "daemon"- Throws:
JSchException- See Also:
setPortForwardingR(String bind_address, int rport, String daemon, Object[] arg)
-
getPortForwardingR
public java.lang.String[] getPortForwardingR() throws JSchExceptionLists the registered remote port forwarding.- Returns:
- a list of "rport:host:hostport"
- Throws:
JSchException
-
parseForwarding
private Session.Forwarding parseForwarding(java.lang.String conf) throws JSchException
The given argument may be "[bind_address:]port:host:hostport" or "[bind_address:]port host:hostport", which is from LocalForward command of ~/.ssh/config .- Throws:
JSchException
-
setPortForwardingL
public int setPortForwardingL(java.lang.String conf) throws JSchExceptionRegisters the local port forwarding. The argument should be in the format like "[bind_address:]port:host:hostport". Ifbind_addressis an empty string or"*", the port should be available from all interfaces. Ifbind_addressis"localhost"or is not given, the listening port will be bound for local use only.- Parameters:
conf- configuration of local port forwarding- Returns:
- an assigned port number
- Throws:
JSchException- See Also:
setPortForwardingL(String bind_address, int lport, String host, int rport)
-
setPortForwardingR
public int setPortForwardingR(java.lang.String conf) throws JSchExceptionRegisters the remote port forwarding. The argument should be in the format like "[bind_address:]port:host:hostport". If the bind_address is not given, the default is to only bind to loopback addresses. If the bind_address is"*"or an empty string, then the forwarding is requested to listen on all interfaces. Note that ifGatewayPortsis"no"on the remote,"localhost"is always used for bind_address. If the specified remote is"0", the TCP port will be allocated on the remote.- Parameters:
conf- configuration of remote port forwarding- Returns:
- an allocated TCP port on the remote.
- Throws:
JSchException- See Also:
setPortForwardingR(String bind_address, int rport, String host, int rport)
-
getStreamForwarder
public Channel getStreamForwarder(java.lang.String host, int port) throws JSchException
Instantiates an instance of stream-forwarder tohost:port. Set I/O stream to the given channel, and then invoke Channel#connect() method.- Parameters:
host- remote host, which the given stream will be plugged to.port- remote port, which the given stream will be plugged to.- Throws:
JSchException
-
_setPortForwardingR
private int _setPortForwardingR(java.lang.String bind_address, int rport) throws JSchException- Throws:
JSchException
-
delPortForwardingR
public void delPortForwardingR(int rport) throws JSchExceptionCancels the remote port forwarding assigned at remote TCP portrport.- Parameters:
rport- remote TCP port- Throws:
JSchException
-
delPortForwardingR
public void delPortForwardingR(java.lang.String bind_address, int rport) throws JSchExceptionCancels the remote port forwarding assigned at remote TCP portrportbound on the interface atbind_address.- Parameters:
bind_address- bind address of the interface on the remoterport- remote TCP port- Throws:
JSchException
-
initDeflater
private void initDeflater(java.lang.String method) throws JSchException- Throws:
JSchException
-
initInflater
private void initInflater(java.lang.String method) throws JSchException- Throws:
JSchException
-
addChannel
void addChannel(Channel channel)
-
setProxy
public void setProxy(Proxy proxy)
-
setHost
public void setHost(java.lang.String host)
-
setPort
public void setPort(int port)
-
setUserName
void setUserName(java.lang.String username)
-
setUserInfo
public void setUserInfo(UserInfo userinfo)
-
getUserInfo
public UserInfo getUserInfo()
-
setInputStream
public void setInputStream(java.io.InputStream in)
-
setOutputStream
public void setOutputStream(java.io.OutputStream out)
-
setX11Host
public void setX11Host(java.lang.String host)
-
setX11Port
public void setX11Port(int port)
-
setX11Cookie
public void setX11Cookie(java.lang.String cookie)
-
setPassword
public void setPassword(java.lang.String password)
-
setPassword
public void setPassword(byte[] password)
-
setConfig
public void setConfig(java.util.Properties newconf)
-
setConfig
public void setConfig(java.util.Hashtable newconf)
-
setConfig
public void setConfig(java.lang.String key, java.lang.String value)
-
getConfig
public java.lang.String getConfig(java.lang.String key)
-
setSocketFactory
public void setSocketFactory(SocketFactory sfactory)
-
isConnected
public boolean isConnected()
-
getTimeout
public int getTimeout()
-
setTimeout
public void setTimeout(int timeout) throws JSchException- Throws:
JSchException
-
getServerVersion
public java.lang.String getServerVersion()
-
getClientVersion
public java.lang.String getClientVersion()
-
setClientVersion
public void setClientVersion(java.lang.String cv)
-
sendIgnore
public void sendIgnore() throws java.lang.Exception- Throws:
java.lang.Exception
-
sendKeepAliveMsg
public void sendKeepAliveMsg() throws java.lang.Exception- Throws:
java.lang.Exception
-
noMoreSessionChannels
public void noMoreSessionChannels() throws java.lang.Exception- Throws:
java.lang.Exception
-
getHostKey
public HostKey getHostKey()
-
getHost
public java.lang.String getHost()
-
getUserName
public java.lang.String getUserName()
-
getPort
public int getPort()
-
setHostKeyAlias
public void setHostKeyAlias(java.lang.String hostKeyAlias)
-
getHostKeyAlias
public java.lang.String getHostKeyAlias()
-
setServerAliveInterval
public void setServerAliveInterval(int interval) throws JSchExceptionSets the interval to send a keep-alive message. If zero is specified, any keep-alive message must not be sent. The default interval is zero.- Parameters:
interval- the specified interval, in milliseconds.- Throws:
JSchException- See Also:
getServerAliveInterval()
-
getServerAliveInterval
public int getServerAliveInterval()
Returns setting for the interval to send a keep-alive message.- See Also:
setServerAliveInterval(int)
-
setServerAliveCountMax
public void setServerAliveCountMax(int count)
Sets the number of keep-alive messages which may be sent without receiving any messages back from the server. If this threshold is reached while keep-alive messages are being sent, the connection will be disconnected. The default value is one.- Parameters:
count- the specified count- See Also:
getServerAliveCountMax()
-
getServerAliveCountMax
public int getServerAliveCountMax()
Returns setting for the threshold to send keep-alive messages.- See Also:
setServerAliveCountMax(int)
-
setDaemonThread
public void setDaemonThread(boolean enable)
-
checkCiphers
private java.lang.String[] checkCiphers(java.lang.String ciphers)
-
checkCipher
static boolean checkCipher(java.lang.String cipher)
-
checkKexes
private java.lang.String[] checkKexes(java.lang.String kexes)
-
checkKex
static boolean checkKex(Session s, java.lang.String kex)
-
checkSignatures
private java.lang.String[] checkSignatures(java.lang.String sigs)
-
setIdentityRepository
public void setIdentityRepository(IdentityRepository identityRepository)
Sets the identityRepository, which will be referred in the public key authentication. The default value isnull.- Parameters:
identityRepository-- See Also:
getIdentityRepository()
-
getIdentityRepository
IdentityRepository getIdentityRepository()
Gets the identityRepository. If this.identityRepository isnull, JSch#getIdentityRepository() will be invoked.- See Also:
JSch.getIdentityRepository()
-
setHostKeyRepository
public void setHostKeyRepository(HostKeyRepository hostkeyRepository)
Sets the hostkeyRepository, which will be referred in checking host keys.- Parameters:
hostkeyRepository-- See Also:
getHostKeyRepository()
-
getHostKeyRepository
public HostKeyRepository getHostKeyRepository()
Gets the hostkeyRepository. If this.hostkeyRepository isnull, JSch#getHostKeyRepository() will be invoked.- See Also:
JSch.getHostKeyRepository()
-
applyConfig
private void applyConfig() throws JSchException- Throws:
JSchException
-
applyConfigChannel
private void applyConfigChannel(ChannelSession channel) throws JSchException
- Throws:
JSchException
-
requestPortForwarding
private void requestPortForwarding() throws JSchException- Throws:
JSchException
-
checkConfig
private void checkConfig(ConfigRepository.Config config, java.lang.String key)
-
-