private static void setPreferredKeyTypesOrder(Session session) { HostKeyRepository hkr = session.getHostKeyRepository(); List<String> known = Stream.of(hkr.getHostKey(hostName(session), null)) .map(HostKey::getType) .collect(toList()); if (!known.isEmpty()) { String serverHostKey = "server_host_key"; //$NON-NLS-1$ String current = session.getConfig(serverHostKey); if (current == null) { session.setConfig(serverHostKey, String.join(",", known)); //$NON-NLS-1$ return; } String knownFirst = Stream.concat( known.stream(), Stream.of(current.split(",")) //$NON-NLS-1$ .filter(s -> !known.contains(s))) .collect(joining(",")); //$NON-NLS-1$ session.setConfig(serverHostKey, knownFirst); } }
public HostKey[] getHostKey(String host, String type) { return knownHosts.getHostKey(host, type); }
public HostKey[] getHostKey() { return knownHosts.getHostKey(); }
public SshHostKey[] getKeys() { List hostKeys = new ArrayList(); HostKey[] keys = hkr.getHostKey(); if (keys != null) { for (int i = 0; i < keys.length; i++) { hostKeys.add(new JschHostKey(keys[i])); } } return (SshHostKey[]) hostKeys.toArray(new SshHostKey[0]); }
private static void setPreferredKeyTypesOrder(Session session) { HostKeyRepository hkr = session.getHostKeyRepository(); List<String> known = Stream.of(hkr.getHostKey(hostName(session), null)) .map(HostKey::getType) .collect(toList()); if (!known.isEmpty()) { String serverHostKey = "server_host_key"; //$NON-NLS-1$ String current = session.getConfig(serverHostKey); if (current == null) { session.setConfig(serverHostKey, String.join(",", known)); //$NON-NLS-1$ return; } String knownFirst = Stream.concat( known.stream(), Stream.of(current.split(",")) //$NON-NLS-1$ .filter(s -> !known.contains(s))) .collect(joining(",")); //$NON-NLS-1$ session.setConfig(serverHostKey, knownFirst); } }
protected SshHostKey[] doGetKeysForHost(String host, String type) { List keys = new ArrayList(); // Stored HostKey[] hk = hkr.getHostKey(host, type); if (hk != null) { for (int i = 0; i < hk.length; i++) { keys.add(new JschHostKey(hk[i])); } } // Try temporary keys for (Iterator i = temporaryKeys.iterator(); i.hasNext();) { SshHostKey k = (SshHostKey) i.next(); if (k.getHost().equals(host) && k.getType().equals(type)) { keys.add(k); } } return keys.size() == 0 ? null : (SshHostKey[]) keys.toArray(new SshHostKey[0]); }
HostKey[] keys = hkr.getHostKey(chost, kex.getKeyAlgorithName()); String _key = Util.byte2str(Util.toBase64(K_S, 0, K_S.length)); for (HostKey key : keys) {
HostKey[] hks = hkr.getHostKey(); if (hks != null) { log.debug("Host keys in {}", hkr.getKnownHostsRepositoryID());
hkr.getHostKey(chost, kex.getKeyAlgorithName()); String _key= Util.byte2str(Util.toBase64(K_S, 0, K_S.length)); for(int j=0; j< keys.length; j++){
hkr.getHostKey(chost, kex.getKeyAlgorithName()); String _key= Util.byte2str(Util.toBase64(K_S, 0, K_S.length)); for(int j=0; j< keys.length; j++){
hkr.getHostKey(chost, kex.getKeyAlgorithName()); String _key= Util.byte2str(Util.toBase64(K_S, 0, K_S.length)); for(int j=0; j< keys.length; j++){
HostKey[] hk = hkr.getHostKey( host, null ); try
HostKey[] hk = hkr.getHostKey( host, null ); try