@Test public void strictHostKeyCheckingIsUsed() { SshUri sshKey = new SshUriProperties.SshUriPropertiesBuilder() .uri("ssh: .hostKey(HOST_KEY) .privateKey(PRIVATE_KEY) .build(); setupSessionFactory(sshKey); factory.configure(hc, session); verify(session).setConfig("StrictHostKeyChecking", "yes"); verifyNoMoreInteractions(session); }
@Override protected void configure(Host hc, Session session) { SshUri sshProperties = sshKeysByHostname.get(hc.getHostName()); String hostKeyAlgorithm = sshProperties.getHostKeyAlgorithm(); if (hostKeyAlgorithm != null) { session.setConfig(SERVER_HOST_KEY, hostKeyAlgorithm); } if (sshProperties.getHostKey() == null || !sshProperties.isStrictHostKeyChecking()) { session.setConfig(STRICT_HOST_KEY_CHECKING, NO_OPTION); } else { session.setConfig(STRICT_HOST_KEY_CHECKING, YES_OPTION); } String preferredAuthentications = sshProperties.getPreferredAuthentications(); if (preferredAuthentications != null) { session.setConfig(PREFERRED_AUTHENTICATIONS, preferredAuthentications); } String proxyHost = sshProperties.getProxyHost(); if (proxyHost != null) { Integer proxyPort = sshProperties.getProxyPort(); Assert.notNull(proxyPort, "Property proxyPort is required, since proxyHost is set."); session.setProxy(new ProxyHTTP(proxyHost, proxyPort)); } }
PropertyBasedSshSessionFactory extends JschConfigSessionFactory { @Override protected void configure(Host hc, Session session) { SshUri sshProperties = sshKeysByHostname.get(hc.getHostName()); String hostKeyAlgorithm = sshProperties.getHostKeyAlgorithm(); if (hostKeyAlgorithm != null) { session.setConfig(SERVER_HOST_KEY, hostKeyAlgorithm); } if (sshProperties.getHostKey() == null || !sshProperties.isStrictHostKeyChecking()) { session.setConfig(STRICT_HOST_KEY_CHECKING, NO_OPTION); } else { session.setConfig(STRICT_HOST_KEY_CHECKING, YES_OPTION); } String preferredAuthentications = sshProperties.getPreferredAuthentications(); if (preferredAuthentications != null) { session.setConfig(PREFERRED_AUTHENTICATIONS, preferredAuthentications); } String proxyHost = sshProperties.getProxyHost(); if (proxyHost != null) { Integer proxyPort = sshProperties.getProxyPort(); Assert.notNull(proxyPort, "Property proxyPort is required, since proxyHost is set."); session.setProxy(new ProxyHTTP(proxyHost, proxyPort)); } } }
PropertyBasedSshSessionFactory extends JschConfigSessionFactory { @Override protected void configure(Host hc, Session session) { SshUri sshProperties = sshKeysByHostname.get(hc.getHostName()); String hostKeyAlgorithm = sshProperties.getHostKeyAlgorithm(); if (hostKeyAlgorithm != null) { session.setConfig(SERVER_HOST_KEY, hostKeyAlgorithm); } if (sshProperties.getHostKey() == null || !sshProperties.isStrictHostKeyChecking()) { session.setConfig(STRICT_HOST_KEY_CHECKING, NO_OPTION); } else { session.setConfig(STRICT_HOST_KEY_CHECKING, YES_OPTION); } String preferredAuthentications = sshProperties.getPreferredAuthentications(); if (preferredAuthentications != null) { session.setConfig(PREFERRED_AUTHENTICATIONS, preferredAuthentications); } String proxyHost = sshProperties.getProxyHost(); if (proxyHost != null) { Integer proxyPort = sshProperties.getProxyPort(); Assert.notNull(proxyPort, "Property proxyPort is required, since proxyHost is set."); session.setProxy(new ProxyHTTP(proxyHost, proxyPort)); } } PropertyBasedSshSessionFactory(Map<String, SshUri> sshKeysByHostname, JSch jSch); }
PropertyBasedSshSessionFactory extends JschConfigSessionFactory { @Override protected void configure(Host hc, Session session) { SshUri sshProperties = sshKeysByHostname.get(hc.getHostName()); String hostKeyAlgorithm = sshProperties.getHostKeyAlgorithm(); if (hostKeyAlgorithm != null) { session.setConfig(SERVER_HOST_KEY, hostKeyAlgorithm); } if (sshProperties.getHostKey() == null || !sshProperties.isStrictHostKeyChecking()) { session.setConfig(STRICT_HOST_KEY_CHECKING, NO_OPTION); } else { session.setConfig(STRICT_HOST_KEY_CHECKING, YES_OPTION); } String preferredAuthentications = sshProperties.getPreferredAuthentications(); if (preferredAuthentications != null) { session.setConfig(PREFERRED_AUTHENTICATIONS, preferredAuthentications); } String proxyHost = sshProperties.getProxyHost(); if (proxyHost != null) { Integer proxyPort = sshProperties.getProxyPort(); Assert.notNull(proxyPort, "Property proxyPort is required, since proxyHost is set."); session.setProxy(new ProxyHTTP(proxyHost, proxyPort)); } } PropertyBasedSshSessionFactory(Map<String, SshUri> sshKeysByHostname, JSch jSch);  }
PropertyBasedSshSessionFactory extends JschConfigSessionFactory { @Override protected void configure(Host hc, Session session) { SshUri sshProperties = sshKeysByHostname.get(hc.getHostName()); String hostKeyAlgorithm = sshProperties.getHostKeyAlgorithm(); if (hostKeyAlgorithm != null) { session.setConfig(SERVER_HOST_KEY, hostKeyAlgorithm); } if (sshProperties.getHostKey() == null || !sshProperties.isStrictHostKeyChecking()) { session.setConfig(STRICT_HOST_KEY_CHECKING, NO_OPTION); } else { session.setConfig(STRICT_HOST_KEY_CHECKING, YES_OPTION); } String preferredAuthentications = sshProperties.getPreferredAuthentications(); if (preferredAuthentications != null) { session.setConfig(PREFERRED_AUTHENTICATIONS, preferredAuthentications); } String proxyHost = sshProperties.getProxyHost(); if (proxyHost != null) { Integer proxyPort = sshProperties.getProxyPort(); Assert.notNull(proxyPort, "Property proxyPort is required, since proxyHost is set."); session.setProxy(new ProxyHTTP(proxyHost, proxyPort)); } } PropertyBasedSshSessionFactory(Map<String, SshUri> sshKeysByHostname, JSch jSch);   }