Class KiwiJSchHelpers


  • public class KiwiJSchHelpers
    extends Object
    Static utilities for working with JSch.
    • Constructor Detail

      • KiwiJSchHelpers

        public KiwiJSchHelpers()
    • Method Detail

      • detectKeyExchangeTypeForHost

        public static Optional<String> detectKeyExchangeTypeForHost​(String host,
                                                                    com.jcraft.jsch.HostKeyRepository knownHosts)
        Detect the key exchange for a given host (or IP address) and HostKeyRepository, which is JSch's encapsulation of the known hosts file.
        Parameters:
        host - the host name or IP to match
        knownHosts - the known hosts
        Returns:
        an Optional containing the detected key exchange type, or an empty Optional
        Implementation Note:
        Finds the first matching known host entry
      • setSessionKeyExchangeType

        public static void setSessionKeyExchangeType​(com.jcraft.jsch.Session session,
                                                     String keyExchangeType)
        Sets the given key exchange type (e.g. ssh-rsa or ecdsa-sha2-nistp256 on the specified session.
        Parameters:
        session - the JSch session
        keyExchangeType - key exchange type
        Implementation Note:
        JSch does not appear to have any constants to use, so it's just raw strings