Class JSch


  • public class JSch
    extends Object
    • Constructor Detail

      • JSch

        public JSch()
    • Method Detail

      • setIdentityRepository

        public void setIdentityRepository​(IdentityRepository identityRepository)
        Sets the identityRepository, which will be referred in the public key authentication.
        Parameters:
        identityRepository - if null is given, the default repository, which usually refers to ~/.ssh/, will be used.
        See Also:
        getIdentityRepository()
      • setConfigRepository

        public void setConfigRepository​(ConfigRepository configRepository)
      • addSession

        protected void addSession​(Session session)
      • removeSession

        protected boolean removeSession​(Session session)
      • setKnownHosts

        public void setKnownHosts​(String filename)
                           throws JSchException
        Sets the instance of KnownHosts, which refers to filename.
        Parameters:
        filename - filename of known_hosts file.
        Throws:
        JSchException - if the given filename is invalid.
        See Also:
        KnownHosts
      • setKnownHosts

        public void setKnownHosts​(InputStream stream)
                           throws JSchException
        Sets the instance of KnownHosts generated with stream.
        Parameters:
        stream - the instance of InputStream from known_hosts file.
        Throws:
        JSchException - if an I/O error occurs.
        See Also:
        KnownHosts
      • getHostKeyRepository

        public HostKeyRepository getHostKeyRepository()
        Returns the current hostkey repository. By the default, this method will the instance of KnownHosts.
        Returns:
        current hostkey repository.
        See Also:
        HostKeyRepository, KnownHosts
      • addIdentity

        public void addIdentity​(String prvkey,
                                String 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 with passphrase.
        Parameters:
        prvkey - filename of the private key.
        passphrase - passphrase for prvkey.
        Throws:
        JSchException - if passphrase is not right.
        See Also:
        addIdentity(String prvkey, byte[] passphrase)
      • addIdentity

        public void addIdentity​(String prvkey,
                                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 with passphrase.
        Parameters:
        prvkey - filename of the private key.
        passphrase - passphrase for prvkey.
        Throws:
        JSchException - if passphrase is not right.
        See Also:
        addIdentity(String prvkey, String pubkey, byte[] passphrase)
      • addIdentity

        public void addIdentity​(String prvkey,
                                String 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 with passphrase.
        Parameters:
        prvkey - filename of the private key.
        pubkey - filename of the public key.
        passphrase - passphrase for prvkey.
        Throws:
        JSchException - if passphrase is 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 with passphrase.
        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 for prvkey.
        Throws:
        JSchException
      • addIdentity

        public void addIdentity​(Identity identity,
                                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 with passphrase.
        Parameters:
        identity - private key.
        passphrase - passphrase for identity.
        Throws:
        JSchException - if passphrase is not right.
      • removeIdentity

        public void removeIdentity​(Identity identity)
                            throws JSchException
        Removes the identity from identityRepository.
        Parameters:
        identity - the indentity to be removed.
        Throws:
        JSchException - if identity is invalid.
      • getIdentityNames

        public Vector getIdentityNames()
                                throws JSchException
        Lists names of identities included in the identityRepository.
        Returns:
        names of identities
        Throws:
        JSchException - if identityReposory has problems.
      • removeAllIdentity

        public void removeAllIdentity()
                               throws JSchException
        Removes all identities from identityRepository.
        Throws:
        JSchException - if identityReposory has problems.
      • getConfig

        public static String getConfig​(String key)
        Returns the config value for the specified key.
        Parameters:
        key - key for the configuration.
        Returns:
        config value
      • setConfig

        public static void setConfig​(Hashtable newconf)
        Sets or Overrides the configuration.
        Parameters:
        newconf - configurations
      • setConfig

        public static void setConfig​(String key,
                                     String value)
        Sets or Overrides the configuration.
        Parameters:
        key - key for the configuration
        value - value for the configuration
      • setLogger

        public static void setLogger​(Logger logger)
        Sets the logger
        Parameters:
        logger - logger
        See Also:
        Logger