Class SshdSessionFactoryBuilder.State.SessionFactory

    • Method Detail

      • getSshConfig

        protected java.io.File getSshConfig​(java.io.File sshDir)
        Description copied from class: SshdSessionFactory
        Determines the ssh config file. The default implementation returns ~/.ssh/config. If the file does not exist and is created later it will be picked up. To not use a config file at all, return null.
        Overrides:
        getSshConfig in class SshdSessionFactory
        Parameters:
        sshDir - representing ~/.ssh/
        Returns:
        the file (need not exist), or null if no config file shall be used
      • getDefaultKnownHostsFiles

        protected java.util.List<java.nio.file.Path> getDefaultKnownHostsFiles​(java.io.File sshDir)
        Description copied from class: SshdSessionFactory
        Gets the list of default user known hosts files. The default returns ~/.ssh/known_hosts and ~/.ssh/known_hosts2. The ssh config UserKnownHostsFile overrides this default.
        Overrides:
        getDefaultKnownHostsFiles in class SshdSessionFactory
        Returns:
        the possibly empty list of default known host file paths.
      • getDefaultIdentities

        protected java.util.List<java.nio.file.Path> getDefaultIdentities​(java.io.File sshDir)
        Description copied from class: SshdSessionFactory
        Gets a list of default identities, i.e., private key files that shall always be tried for public key authentication. Typically those are ~/.ssh/id_dsa, ~/.ssh/id_rsa, and so on. The default implementation returns the files defined in SshConstants.DEFAULT_IDENTITIES.
        Overrides:
        getDefaultIdentities in class SshdSessionFactory
        Parameters:
        sshDir - the directory that represents ~/.ssh/
        Returns:
        a possibly empty list of paths containing default identities (private keys)
      • getDefaultPreferredAuthentications

        protected java.lang.String getDefaultPreferredAuthentications()
        Description copied from class: SshdSessionFactory
        Gets the list of default preferred authentication mechanisms. If null is returned the openssh default list will be in effect. If the ssh config defines PreferredAuthentications the value from the ssh config takes precedence.
        Overrides:
        getDefaultPreferredAuthentications in class SshdSessionFactory
        Returns:
        a comma-separated list of mechanism names, or null if none
      • getDefaultKeys

        protected java.lang.Iterable<java.security.KeyPair> getDefaultKeys​(java.io.File sshDir)
        Description copied from class: SshdSessionFactory
        Determines the default keys. The default implementation will lazy load the default identity files.

        Subclasses may override and return an Iterable of whatever keys are appropriate. If the returned iterable lazily loads keys, it should be an instance of AbstractResourceKeyPairProvider so that the session can later pass it the password provider wrapped as a FilePasswordProvider via AbstractResourceKeyPairProvider#setPasswordFinder(FilePasswordProvider) so that encrypted, password-protected keys can be loaded.

        The default implementation uses exactly this mechanism; class CachingKeyPairProvider may serve as a model for a customized lazy-loading Iterable implementation

        If the Iterable returned has the keys already pre-loaded or otherwise doesn't need to decrypt encrypted keys, it can be any Iterable, for instance a simple List.

        Overrides:
        getDefaultKeys in class SshdSessionFactory
        Parameters:
        sshDir - to look in for keys
        Returns:
        an Iterable over the default keys
      • createServerKeyDatabase

        protected ServerKeyDatabase createServerKeyDatabase​(java.io.File homeDir,
                                                            java.io.File sshDir)
        Description copied from class: SshdSessionFactory
        Creates a ServerKeyDatabase to verify server host keys. The default implementation returns a ServerKeyDatabase that recognizes the two openssh standard files ~/.ssh/known_hosts and ~/.ssh/known_hosts2 as well as any files configured via the UserKnownHostsFile option in the ssh config file.
        Overrides:
        createServerKeyDatabase in class SshdSessionFactory
        Parameters:
        homeDir - home directory to use for ~ replacement
        sshDir - representing ~/.ssh/
        Returns:
        the ServerKeyDatabase
      • createSshConfigStore

        protected SshConfigStore createSshConfigStore​(java.io.File homeDir,
                                                      java.io.File configFile,
                                                      java.lang.String localUserName)
        Description copied from class: SshdSessionFactory
        Obtains a SshConfigStore, or null if not SSH config is to be used. The default implementation returns null if configFile == null and otherwise an OpenSSH-compatible store reading host entries from the given file.
        Overrides:
        createSshConfigStore in class SshdSessionFactory
        Parameters:
        homeDir - may be used for ~-replacements by the returned config store
        configFile - to use, or null if none
        localUserName - user name of the current user on the local OS
        Returns:
        A SshConfigStore, or null if none is to be used