com.jcraft.jsch.Session Class Reference

A Session represents a connection to a SSH server. More...

Collaboration diagram for com.jcraft.jsch.Session:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void connect () throws JSchException
 opens the connection, using the timeout set with setTimeout.
void connect (int connectTimeout) throws JSchException
 opens the connection, using the specified timeout.
void rekey () throws Exception
 initiates a new key exchange.

Protected Attributes

boolean daemon_thread = false

Package Functions

 Session (JSch jsch) throws JSchException
 creates a new session object from a JSch.

Package Attributes

String[] guess = null
boolean x11_forwarding = false
boolean agent_forwarding = false
InputStream in = null
OutputStream out = null
Buffer buf
Packet packet
SocketFactory socket_factory = null
String host = "127.0.0.1"
int port = 22
String username = null
byte[] password = null
JSch jsch

Static Package Attributes

static final int SSH_MSG_DISCONNECT = 1
static final int SSH_MSG_IGNORE = 2
static final int SSH_MSG_UNIMPLEMENTED = 3
static final int SSH_MSG_DEBUG = 4
static final int SSH_MSG_SERVICE_REQUEST = 5
static final int SSH_MSG_SERVICE_ACCEPT = 6
static final int SSH_MSG_KEXINIT = 20
static final int SSH_MSG_NEWKEYS = 21
static final int SSH_MSG_KEXDH_INIT = 30
static final int SSH_MSG_KEXDH_REPLY = 31
static final int SSH_MSG_KEX_DH_GEX_GROUP = 31
static final int SSH_MSG_KEX_DH_GEX_INIT = 32
static final int SSH_MSG_KEX_DH_GEX_REPLY = 33
static final int SSH_MSG_KEX_DH_GEX_REQUEST = 34
static final int SSH_MSG_GLOBAL_REQUEST = 80
static final int SSH_MSG_REQUEST_SUCCESS = 81
static final int SSH_MSG_REQUEST_FAILURE = 82
static final int SSH_MSG_CHANNEL_OPEN = 90
static final int SSH_MSG_CHANNEL_OPEN_CONFIRMATION = 91
static final int SSH_MSG_CHANNEL_OPEN_FAILURE = 92
static final int SSH_MSG_CHANNEL_WINDOW_ADJUST = 93
static final int SSH_MSG_CHANNEL_DATA = 94
static final int SSH_MSG_CHANNEL_EXTENDED_DATA = 95
static final int SSH_MSG_CHANNEL_EOF = 96
static final int SSH_MSG_CHANNEL_CLOSE = 97
static final int SSH_MSG_CHANNEL_REQUEST = 98
static final int SSH_MSG_CHANNEL_SUCCESS = 99
static final int SSH_MSG_CHANNEL_FAILURE = 100
static Random random
static final int buffer_margin

Private Member Functions

KeyExchange receive_kexinit (Buffer buf) throws Exception
 receives and interprets an SSH_MSG_KEXINIT packet from the server.
void send_kexinit () throws Exception
void send_newkeys () throws Exception
void checkHost (String chost, int port, KeyExchange kex) throws JSchException

Private Attributes

byte[] V_S
byte[] V_C = Util.str2byte("SSH-2.0-"+version)
byte[] I_C
byte[] I_S
byte[] K_S
byte[] session_id
byte[] IVc2s
byte[] IVs2c
byte[] Ec2s
byte[] Es2c
byte[] MACc2s
byte[] MACs2c
int seqi = 0
int seqo = 0
Cipher s2ccipher
Cipher c2scipher
MAC s2cmac
MAC c2smac
byte[] s2cmac_result1
byte[] s2cmac_result2
Compression deflater
Compression inflater
IO io
Socket socket
int timeout = 0
volatile boolean isConnected = false
boolean isAuthed = false
Thread connectThread = null
Object lock = new Object()
java.util.Hashtable config = null
Proxy proxy = null
UserInfo userinfo
String hostKeyAlias = null
int serverAliveInterval = 0
int serverAliveCountMax = 1
long kex_start_time = 0L
boolean in_kex = false

Static Private Attributes

static final String version = "JSCH-0.1.45"
static final int PACKET_MAX_SIZE = 256 * 1024

Detailed Description

A Session represents a connection to a SSH server.

One session can contain multiple Channels of various types, created with openChannel.

A session is opened with connect() and closed with disconnect. The fact that a Session implements Runnable is an implementation detail.

Definition at line 46 of file Session.java.


Constructor & Destructor Documentation

com.jcraft.jsch.Session.Session ( JSch  jsch  )  throws JSchException [package]

creates a new session object from a JSch.

Definition at line 167 of file Session.java.

References com.jcraft.jsch.Session.buf, com.jcraft.jsch.Session.jsch, and com.jcraft.jsch.Session.packet.


Member Function Documentation

void com.jcraft.jsch.Session.checkHost ( String  chost,
int  port,
KeyExchange  kex 
) throws JSchException [private]
void com.jcraft.jsch.Session.connect ( int  connectTimeout  )  throws JSchException

opens the connection, using the specified timeout.

Exceptions:
JSchException if this session is already connected, or some other error occurs during connecting. (If there was some other exception, it is appended as the cause to the JSchException thrown.)

Definition at line 189 of file Session.java.

References com.jcraft.jsch.JSch.addSession(), com.jcraft.jsch.Session.buf, com.jcraft.jsch.Buffer.buffer, com.jcraft.jsch.Session.checkHost(), com.jcraft.jsch.Session.connectThread, com.jcraft.jsch.SocketFactory.createSocket(), com.jcraft.jsch.Session.daemon_thread, com.jcraft.jsch.IO.getByte(), com.jcraft.jsch.JSchPartialAuthException.getMethods(), com.jcraft.jsch.Session.host, com.jcraft.jsch.Session.in, com.jcraft.jsch.Session.in_kex, com.jcraft.jsch.Session.io, com.jcraft.jsch.Session.isAuthed, com.jcraft.jsch.Session.isConnected, com.jcraft.jsch.Session.jsch, com.jcraft.jsch.Session.kex_start_time, com.jcraft.jsch.Session.lock, com.jcraft.jsch.KeyExchange.next(), com.jcraft.jsch.Session.out, com.jcraft.jsch.Session.packet, com.jcraft.jsch.Session.password, com.jcraft.jsch.Session.port, com.jcraft.jsch.Session.proxy, com.jcraft.jsch.IO.put(), com.jcraft.jsch.Buffer.putByte(), com.jcraft.jsch.Session.random, com.jcraft.jsch.Session.receive_kexinit(), com.jcraft.jsch.Packet.reset(), com.jcraft.jsch.Session.send_kexinit(), com.jcraft.jsch.Session.send_newkeys(), com.jcraft.jsch.IO.setInputStream(), com.jcraft.jsch.IO.setOutputStream(), com.jcraft.jsch.Session.socket, com.jcraft.jsch.Session.socket_factory, com.jcraft.jsch.Session.SSH_MSG_DISCONNECT, com.jcraft.jsch.Session.SSH_MSG_KEXINIT, com.jcraft.jsch.Session.SSH_MSG_NEWKEYS, com.jcraft.jsch.KeyExchange.STATE_END, com.jcraft.jsch.Session.timeout, com.jcraft.jsch.Session.V_C, and com.jcraft.jsch.Session.V_S.

void com.jcraft.jsch.Session.connect (  )  throws JSchException

opens the connection, using the timeout set with setTimeout.

Exceptions:
JSchException if this session is already connected.
See also:
connect(int)

Definition at line 179 of file Session.java.

References com.jcraft.jsch.Session.timeout.

Referenced by edu.rice.cs.hpc.remote.tunnel.SSHManager.connect(), edu.rice.cs.hpc.remote.tunnel.LocalTunneling.connect(), and edu.rice.cs.hpc.remote.tunnel.PortForwarding.main().

KeyExchange com.jcraft.jsch.Session.receive_kexinit ( Buffer  buf  )  throws Exception [private]
void com.jcraft.jsch.Session.rekey (  )  throws Exception

initiates a new key exchange.

This is necessary for some changes on the configuration to become active, like compression or encryption mode.

Definition at line 593 of file Session.java.

References com.jcraft.jsch.Session.send_kexinit().

void com.jcraft.jsch.Session.send_kexinit (  )  throws Exception [private]
void com.jcraft.jsch.Session.send_newkeys (  )  throws Exception [private]

Member Data Documentation

boolean com.jcraft.jsch.Session.agent_forwarding = false [package]

Definition at line 127 of file Session.java.

Referenced by com.jcraft.jsch.RequestAgentForwarding.request().

final int com.jcraft.jsch.Session.buffer_margin [static, package]
Initial value:
 32 + 
            20 + 
            32

Definition at line 139 of file Session.java.

Definition at line 105 of file Session.java.

Definition at line 107 of file Session.java.

java.util.Hashtable com.jcraft.jsch.Session.config = null [private]

Definition at line 143 of file Session.java.

Thread com.jcraft.jsch.Session.connectThread = null [private]

Definition at line 123 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

boolean com.jcraft.jsch.Session.daemon_thread = false [protected]

Definition at line 112 of file Session.java.

byte [] com.jcraft.jsch.Session.Ec2s [private]

Definition at line 95 of file Session.java.

byte [] com.jcraft.jsch.Session.Es2c [private]

Definition at line 96 of file Session.java.

String [] com.jcraft.jsch.Session.guess = null [package]

Definition at line 103 of file Session.java.

Referenced by com.jcraft.jsch.Session.receive_kexinit().

String com.jcraft.jsch.Session.host = "127.0.0.1" [package]
String com.jcraft.jsch.Session.hostKeyAlias = null [private]

Definition at line 148 of file Session.java.

Referenced by com.jcraft.jsch.Session.checkHost().

byte [] com.jcraft.jsch.Session.I_C [private]
byte [] com.jcraft.jsch.Session.I_S [private]

Definition at line 88 of file Session.java.

Referenced by com.jcraft.jsch.Session.receive_kexinit().

InputStream com.jcraft.jsch.Session.in = null [package]

Definition at line 129 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

boolean com.jcraft.jsch.Session.in_kex = false [private]

Definition at line 113 of file Session.java.

Definition at line 115 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

boolean com.jcraft.jsch.Session.isAuthed = false [private]
volatile boolean com.jcraft.jsch.Session.isConnected = false [private]
byte [] com.jcraft.jsch.Session.IVc2s [private]

Definition at line 93 of file Session.java.

byte [] com.jcraft.jsch.Session.IVs2c [private]

Definition at line 94 of file Session.java.

byte [] com.jcraft.jsch.Session.K_S [private]

Definition at line 89 of file Session.java.

Referenced by com.jcraft.jsch.Session.checkHost().

Object com.jcraft.jsch.Session.lock = new Object() [private]

Definition at line 124 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

byte [] com.jcraft.jsch.Session.MACc2s [private]

Definition at line 97 of file Session.java.

byte [] com.jcraft.jsch.Session.MACs2c [private]

Definition at line 98 of file Session.java.

OutputStream com.jcraft.jsch.Session.out = null [package]
final int com.jcraft.jsch.Session.PACKET_MAX_SIZE = 256 * 1024 [static, private]

Definition at line 82 of file Session.java.

byte [] com.jcraft.jsch.Session.password = null [package]

Definition at line 160 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

int com.jcraft.jsch.Session.port = 22 [package]

Definition at line 145 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

Random com.jcraft.jsch.Session.random [static, package]

Definition at line 104 of file Session.java.

Definition at line 106 of file Session.java.

Definition at line 109 of file Session.java.

Definition at line 110 of file Session.java.

int com.jcraft.jsch.Session.seqi = 0 [private]

Definition at line 100 of file Session.java.

int com.jcraft.jsch.Session.seqo = 0 [private]

Definition at line 101 of file Session.java.

Definition at line 150 of file Session.java.

Definition at line 149 of file Session.java.

Definition at line 91 of file Session.java.

Definition at line 116 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

Definition at line 137 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

final int com.jcraft.jsch.Session.SSH_MSG_CHANNEL_CLOSE = 97 [static, package]

Definition at line 77 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_CHANNEL_DATA = 94 [static, package]

Definition at line 74 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_CHANNEL_EOF = 96 [static, package]

Definition at line 76 of file Session.java.

Definition at line 75 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_CHANNEL_FAILURE = 100 [static, package]

Definition at line 80 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_CHANNEL_OPEN = 90 [static, package]

Definition at line 70 of file Session.java.

Definition at line 71 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_CHANNEL_OPEN_FAILURE = 92 [static, package]

Definition at line 72 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_CHANNEL_REQUEST = 98 [static, package]

Definition at line 78 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_CHANNEL_SUCCESS = 99 [static, package]

Definition at line 79 of file Session.java.

Definition at line 73 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_DEBUG = 4 [static, package]

Definition at line 56 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_DISCONNECT = 1 [static, package]

Definition at line 53 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

final int com.jcraft.jsch.Session.SSH_MSG_GLOBAL_REQUEST = 80 [static, package]

Definition at line 67 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_IGNORE = 2 [static, package]

Definition at line 54 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_KEX_DH_GEX_GROUP = 31 [static, package]

Definition at line 63 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_KEX_DH_GEX_INIT = 32 [static, package]

Definition at line 64 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_KEX_DH_GEX_REPLY = 33 [static, package]

Definition at line 65 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_KEX_DH_GEX_REQUEST = 34 [static, package]

Definition at line 66 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_KEXDH_INIT = 30 [static, package]

Definition at line 61 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_KEXDH_REPLY = 31 [static, package]

Definition at line 62 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_KEXINIT = 20 [static, package]
final int com.jcraft.jsch.Session.SSH_MSG_NEWKEYS = 21 [static, package]
final int com.jcraft.jsch.Session.SSH_MSG_REQUEST_FAILURE = 82 [static, package]

Definition at line 69 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_REQUEST_SUCCESS = 81 [static, package]

Definition at line 68 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_SERVICE_ACCEPT = 6 [static, package]

Definition at line 58 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_SERVICE_REQUEST = 5 [static, package]

Definition at line 57 of file Session.java.

final int com.jcraft.jsch.Session.SSH_MSG_UNIMPLEMENTED = 3 [static, package]

Definition at line 55 of file Session.java.

Definition at line 117 of file Session.java.

Referenced by com.jcraft.jsch.Session.connect().

Definition at line 146 of file Session.java.

Referenced by com.jcraft.jsch.Session.checkHost().

String com.jcraft.jsch.Session.username = null [package]

Definition at line 159 of file Session.java.

byte [] com.jcraft.jsch.Session.V_C = Util.str2byte("SSH-2.0-"+version) [private]
byte [] com.jcraft.jsch.Session.V_S [private]
final String com.jcraft.jsch.Session.version = "JSCH-0.1.45" [static, private]

Definition at line 49 of file Session.java.

boolean com.jcraft.jsch.Session.x11_forwarding = false [package]

Definition at line 126 of file Session.java.

Referenced by com.jcraft.jsch.RequestX11.request().


The documentation for this class was generated from the following file:

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1