Package org.kiwiproject.jsch
Class KiwiJSchHelpers
java.lang.Object
org.kiwiproject.jsch.KiwiJSchHelpers
Static utilities for working with JSch.
-
Method Summary
Modifier and TypeMethodDescriptiondetectKeyExchangeTypeForHost(String host, com.jcraft.jsch.HostKeyRepository knownHosts) Detect the key exchange for a given host (or IP address) andHostKeyRepository, which is JSch's encapsulation of theknown_hostsfile.static voidsetSessionKeyExchangeType(com.jcraft.jsch.Session session, String keyExchangeType) Sets the given key exchange type, e.g.
-
Method Details
-
detectKeyExchangeTypeForHost
public static Optional<String> detectKeyExchangeTypeForHost(String host, com.jcraft.jsch.HostKeyRepository knownHosts) Detect the key exchange for a given host (or IP address) andHostKeyRepository, which is JSch's encapsulation of theknown_hostsfile.This method supports only a subset of the possible formats in
known_hosts. The supported formats are:hostname, e.g.dev-svc-1.acme.comip_address, e.g.192.168.1.150hostname,ip_address, e,g,dev-svc-1.acme.com,192.168.1.150
known_hostscan have various other formats, but we do not support them at the present time. See this discussion on known_hosts formats for additional information.- Parameters:
host- the host name or IP to matchknownHosts- 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-rsaorecdsa-sha2-nistp256on the specified session.- Parameters:
session- the JSch sessionkeyExchangeType- key exchange type- Implementation Note:
- JSch does not appear to have any constants to use, so it's just raw strings
-