Package com.jcraft.jsch
Class JSch
java.lang.Object
com.jcraft.jsch.JSch
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIdentity(Identity identity, byte[] passphrase) Sets the private key, which will be referred in the public key authentication.voidaddIdentity(String prvkey) Sets the private key, which will be referred in the public key authentication.voidaddIdentity(String prvkey, byte[] passphrase) Sets the private key, which will be referred in the public key authentication.voidaddIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passphrase) Sets the private key, which will be referred in the public key authentication.voidaddIdentity(String prvkey, String passphrase) Sets the private key, which will be referred in the public key authentication.voidaddIdentity(String prvkey, String pubkey, byte[] passphrase) Sets the private key, which will be referred in the public key authentication.protected voidaddSession(Session session) static StringReturns the config value for the specified key.Returns the current hostkey repository.Lists names of identities included in the identityRepository.Returns a logger to be used for this particular instance of JSchstatic LoggerReturns the statically set logger, i.e.getSession(String host) Instantiates theSessionobject withhost.getSession(String username, String host) Instantiates theSessionobject withusernameandhost.getSession(String username, String host, int port) Instantiates theSessionobject with givenusername,hostandport.voidRemoves all identities from identityRepository.voidremoveIdentity(Identity identity) Removes the identity from identityRepository.voidremoveIdentity(String name) Deprecated.use #removeIdentity(Identity identity)protected booleanremoveSession(Session session) static voidSets or Overrides the configuration.static voidSets or Overrides the configuration.voidsetConfigRepository(ConfigRepository configRepository) voidSets the hostkey repository.voidsetIdentityRepository(IdentityRepository identityRepository) Sets theidentityRepository, which will be referred in the public key authentication.voidsetInstanceLogger(Logger logger) Sets a logger to be used for this particular instance of JSchvoidsetKnownHosts(InputStream stream) Sets the instance ofKnownHostsgenerated withstream.voidsetKnownHosts(String filename) Sets the instance ofKnownHosts, which refers tofilename.static voidSets the logger
-
Field Details
-
VERSION
The version number.
-
-
Constructor Details
-
JSch
public JSch()
-
-
Method Details
-
setIdentityRepository
Sets theidentityRepository, which will be referred in the public key authentication.- Parameters:
identityRepository- ifnullis given, the default repository, which usually refers to ~/.ssh/, will be used.- See Also:
-
getIdentityRepository
-
getConfigRepository
-
setConfigRepository
-
getSession
Instantiates theSessionobject withhost. 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.- Parameters:
host- hostname- Returns:
- the instance of
Sessionclass. - Throws:
JSchException- ifusernameorhostare invalid.- See Also:
-
getSession
Instantiates theSessionobject withusernameandhost. The TCP port 22 will be used in making the connection. Note that the TCP connection must not be established until Session#connect().- Parameters:
username- user namehost- hostname- Returns:
- the instance of
Sessionclass. - Throws:
JSchException- ifusernameorhostare invalid.- See Also:
-
getSession
Instantiates theSessionobject with givenusername,hostandport. Note that the TCP connection must not be established until Session#connect().- Parameters:
username- user namehost- hostnameport- port number- Returns:
- the instance of
Sessionclass. - Throws:
JSchException- ifusernameorhostare invalid.- See Also:
-
addSession
-
removeSession
-
setHostKeyRepository
Sets the hostkey repository.- Parameters:
hkrepo-- See Also:
-
setKnownHosts
Sets the instance ofKnownHosts, which refers tofilename.- Parameters:
filename- filename of known_hosts file.- Throws:
JSchException- if the given filename is invalid.- See Also:
-
setKnownHosts
Sets the instance ofKnownHostsgenerated withstream.- Parameters:
stream- the instance of InputStream from known_hosts file.- Throws:
JSchException- if an I/O error occurs.- See Also:
-
getHostKeyRepository
Returns the current hostkey repository. By the default, this method will the instance ofKnownHosts.- Returns:
- current hostkey repository.
- See Also:
-
addIdentity
Sets the private key, which will be referred in the public key authentication.- Parameters:
prvkey- filename of the private key.- Throws:
JSchException- ifprvkeyis invalid.- See Also:
-
addIdentity
Sets the private key, which will be referred in the public key authentication. Before registering it into identityRepository, it will be deciphered withpassphrase.- Parameters:
prvkey- filename of the private key.passphrase- passphrase forprvkey.- Throws:
JSchException- ifpassphraseis not right.- See Also:
-
addIdentity
Sets the private key, which will be referred in the public key authentication. Before registering it into identityRepository, it will be deciphered withpassphrase.- Parameters:
prvkey- filename of the private key.passphrase- passphrase forprvkey.- Throws:
JSchException- ifpassphraseis not right.- See Also:
-
addIdentity
Sets the private key, which will be referred in the public key authentication. Before registering it into identityRepository, it will be deciphered withpassphrase.- Parameters:
prvkey- filename of the private key.pubkey- filename of the public key.passphrase- passphrase forprvkey.- Throws:
JSchException- ifpassphraseis not right.
-
addIdentity
public void addIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passphrase) throws JSchException Sets the private key, which will be referred in the public key authentication. Before registering it into identityRepository, it will be deciphered withpassphrase.- Parameters:
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 forprvkey.- Throws:
JSchException
-
addIdentity
Sets the private key, which will be referred in the public key authentication. Before registering it into identityRepository, it will be deciphered withpassphrase.- Parameters:
identity- private key.passphrase- passphrase foridentity.- Throws:
JSchException- ifpassphraseis not right.
-
removeIdentity
Deprecated.use #removeIdentity(Identity identity)- Throws:
JSchException
-
removeIdentity
Removes the identity from identityRepository.- Parameters:
identity- the indentity to be removed.- Throws:
JSchException- ifidentityis invalid.
-
getIdentityNames
Lists names of identities included in the identityRepository.- Returns:
- names of identities
- Throws:
JSchException- if identityReposory has problems.
-
removeAllIdentity
Removes all identities from identityRepository.- Throws:
JSchException- if identityReposory has problems.
-
getConfig
Returns the config value for the specified key.- Parameters:
key- key for the configuration.- Returns:
- config value
-
setConfig
Sets or Overrides the configuration.- Parameters:
newconf- configurations
-
setConfig
Sets or Overrides the configuration.- Parameters:
key- key for the configurationvalue- value for the configuration
-
setLogger
Sets the logger- Parameters:
logger- logger ornullif no logging should take place- See Also:
-
getInstanceLogger
Returns a logger to be used for this particular instance of JSch- Returns:
- The logger that is used by this instance. If no particular logger has been set, the statically set logger is returned.
-
setInstanceLogger
Sets a logger to be used for this particular instance of JSch- Parameters:
logger- The logger to be used ornullif the statically set logger should be used
-
getLogger
Returns the statically set logger, i.e. the logger being used by all JSch instances without explicitly set logger.- Returns:
- The logger
-