public class JSch extends Object
Modifier and Type | Field and Description |
---|---|
static String |
VERSION
The version number.
|
Constructor and Description |
---|
JSch() |
Modifier and Type | Method and Description |
---|---|
void |
addIdentity(Identity identity,
byte[] passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(String prvkey)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(String prvkey,
byte[] passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(String name,
byte[] prvkey,
byte[] pubkey,
byte[] passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(String prvkey,
String passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
void |
addIdentity(String prvkey,
String pubkey,
byte[] passphrase)
Sets the private key, which will be referred in
the public key authentication.
|
protected void |
addSession(Session session) |
static String |
getConfig(String key)
Returns the config value for the specified key.
|
ConfigRepository |
getConfigRepository() |
HostKeyRepository |
getHostKeyRepository()
Returns the current hostkey repository.
|
Vector |
getIdentityNames()
Lists names of identities included in the identityRepository.
|
IdentityRepository |
getIdentityRepository() |
Session |
getSession(String host)
Instantiates the
Session object with
host . |
Session |
getSession(String username,
String host)
Instantiates the
Session object with
username and host . |
Session |
getSession(String username,
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(String name)
Deprecated.
use #removeIdentity(Identity identity)
|
protected boolean |
removeSession(Session session) |
static void |
setConfig(Hashtable newconf)
Sets or Overrides the configuration.
|
static void |
setConfig(String key,
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(InputStream stream)
Sets the instance of
KnownHosts generated with
stream . |
void |
setKnownHosts(String filename)
Sets the instance of
KnownHosts , which refers
to filename . |
static void |
setLogger(Logger logger)
Sets the logger
|
public static final 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(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(String username, 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(String username, 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(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(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(String prvkey) throws JSchException
prvkey
- filename of the private key.JSchException
- if prvkey
is invalid.addIdentity(String prvkey, String passphrase)
public void addIdentity(String prvkey, 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(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(String prvkey, 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(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(String name) throws JSchException
JSchException
public void removeIdentity(Identity identity) throws JSchException
identity
- the indentity to be removed.JSchException
- if identity
is invalid.public Vector getIdentityNames() throws JSchException
JSchException
- if identityReposory has problems.public void removeAllIdentity() throws JSchException
JSchException
- if identityReposory has problems.public static String getConfig(String key)
key
- key for the configuration.public static void setConfig(Hashtable newconf)
newconf
- configurationspublic static void setConfig(String key, String value)
key
- key for the configurationvalue
- value for the configurationCopyright © 2015 JCraft,Inc.. All rights reserved.