public class JSch
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
VERSION
The version number.
|
构造器和说明 |
---|
JSch() |
限定符和类型 | 方法和说明 |
---|---|
void |
addIdentity(Identity identity,
byte[] passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(java.lang.String prvkey)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(java.lang.String prvkey,
byte[] passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(java.lang.String name,
byte[] prvkey,
byte[] pubkey,
byte[] passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(java.lang.String prvkey,
java.lang.String passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(java.lang.String prvkey,
java.lang.String pubkey,
byte[] passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
protected void |
addSession(Session session) |
static java.lang.String |
getConfig(java.lang.String key)
Returns the config value for the specified key.
|
ConfigRepository |
getConfigRepository() |
HostKeyRepository |
getHostKeyRepository()
Returns the current hostkey repository.
|
java.util.Vector |
getIdentityNames()
Lists names of identities included in the identityRepository.
|
IdentityRepository |
getIdentityRepository() |
Session |
getSession(java.lang.String host)
Instantiates the
Session object with
host . |
Session |
getSession(java.lang.String username,
java.lang.String host)
Instantiates the
Session object with
username and host . |
Session |
getSession(java.lang.String username,
java.lang.String host,
int port)
Instantiates the
Session object with given
username , host and port . |
void |
removeAllIdentity()
Removes all identities from identityRepository.
|
void |
removeIdentity(Identity identity)
Removes the identity from identityRepository.
|
void |
removeIdentity(java.lang.String name)
已过时。
use #removeIdentity(Identity identity)
|
protected boolean |
removeSession(Session session) |
static void |
setConfig(java.util.Hashtable newconf)
Sets or Overrides the configuration.
|
static void |
setConfig(java.lang.String key,
java.lang.String value)
Sets or Overrides the configuration.
|
void |
setConfigRepository(ConfigRepository configRepository) |
void |
setHostKeyRepository(HostKeyRepository hkrepo)
Sets the hostkey repository.
|
void |
setIdentityRepository(IdentityRepository identityRepository)
Sets the
identityRepository , which will be referred
in the public key authentication. |
void |
setKnownHosts(java.io.InputStream stream)
Sets the instance of
KnownHosts generated with
stream . |
void |
setKnownHosts(java.lang.String filename)
Sets the instance of
KnownHosts , which refers
to filename . |
static void |
setLogger(Logger logger)
Sets the logger
|
public static final java.lang.String VERSION
public void setIdentityRepository(IdentityRepository identityRepository)
identityRepository
, which will be referred
in the public key authentication.identityRepository
- if null
is given,
the default repository, which usually refers to ~/.ssh/, will be used.getIdentityRepository()
public IdentityRepository getIdentityRepository()
public ConfigRepository getConfigRepository()
public void setConfigRepository(ConfigRepository configRepository)
public Session getSession(java.lang.String host) throws JSchException
Session
object with
host
. The user name and port number will be retrieved from
ConfigRepository. If user name is not given,
the system property "user.name" will be referred.host
- hostnameSession
class.JSchException
- if username
or host
are invalid.getSession(String username, String host, int port)
,
Session
,
ConfigRepository
public Session getSession(java.lang.String username, java.lang.String host) throws JSchException
Session
object with
username
and host
.
The TCP port 22 will be used in making the connection.
Note that the TCP connection must not be established
until Session#connect().username
- user namehost
- hostnameSession
class.JSchException
- if username
or host
are invalid.getSession(String username, String host, int port)
,
Session
public Session getSession(java.lang.String username, java.lang.String host, int port) throws JSchException
Session
object with given
username
, host
and port
.
Note that the TCP connection must not be established
until Session#connect().username
- user namehost
- hostnameport
- port numberSession
class.JSchException
- if username
or host
are invalid.getSession(String username, String host, int port)
,
Session
protected void addSession(Session session)
protected boolean removeSession(Session session)
public void setHostKeyRepository(HostKeyRepository hkrepo)
hkrepo
- HostKeyRepository
,
KnownHosts
public void setKnownHosts(java.lang.String filename) throws JSchException
KnownHosts
, which refers
to filename
.filename
- filename of known_hosts file.JSchException
- if the given filename is invalid.KnownHosts
public void setKnownHosts(java.io.InputStream stream) throws JSchException
KnownHosts
generated with
stream
.stream
- the instance of InputStream from known_hosts file.JSchException
- if an I/O error occurs.KnownHosts
public HostKeyRepository getHostKeyRepository()
KnownHosts
.HostKeyRepository
,
KnownHosts
public void addIdentity(java.lang.String prvkey) throws JSchException
prvkey
- filename of the private key.JSchException
- if prvkey
is invalid.addIdentity(String prvkey, String passphrase)
public void addIdentity(java.lang.String prvkey, java.lang.String passphrase) throws JSchException
passphrase
.prvkey
- filename of the private key.passphrase
- passphrase for prvkey
.JSchException
- if passphrase
is not right.addIdentity(String prvkey, byte[] passphrase)
public void addIdentity(java.lang.String prvkey, byte[] passphrase) throws JSchException
passphrase
.prvkey
- filename of the private key.passphrase
- passphrase for prvkey
.JSchException
- if passphrase
is not right.addIdentity(String prvkey, String pubkey, byte[] passphrase)
public void addIdentity(java.lang.String prvkey, java.lang.String pubkey, byte[] passphrase) throws JSchException
passphrase
.prvkey
- filename of the private key.pubkey
- filename of the public key.passphrase
- passphrase for prvkey
.JSchException
- if passphrase
is not right.public void addIdentity(java.lang.String name, byte[] prvkey, byte[] pubkey, byte[] passphrase) throws JSchException
passphrase
.name
- name of the identity to be used to
retrieve it in the identityRepository.prvkey
- private key in byte array.pubkey
- public key in byte array.passphrase
- passphrase for prvkey
.JSchException
public void addIdentity(Identity identity, byte[] passphrase) throws JSchException
passphrase
.identity
- private key.passphrase
- passphrase for identity
.JSchException
- if passphrase
is not right.public void removeIdentity(java.lang.String name) throws JSchException
JSchException
public void removeIdentity(Identity identity) throws JSchException
identity
- the indentity to be removed.JSchException
- if identity
is invalid.public java.util.Vector getIdentityNames() throws JSchException
JSchException
- if identityReposory has problems.public void removeAllIdentity() throws JSchException
JSchException
- if identityReposory has problems.public static java.lang.String getConfig(java.lang.String key)
key
- key for the configuration.public static void setConfig(java.util.Hashtable newconf)
newconf
- configurationspublic static void setConfig(java.lang.String key, java.lang.String value)
key
- key for the configurationvalue
- value for the configuration