1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
|
/*
* Copyright (C) 2018, 2024 Thomas Wolf <twolf@apache.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.transport.sshd;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.security.KeyPair;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.apache.sshd.client.ClientBuilder;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.auth.UserAuthFactory;
import org.apache.sshd.client.auth.keyboard.UserAuthKeyboardInteractiveFactory;
import org.apache.sshd.client.auth.password.UserAuthPasswordFactory;
import org.apache.sshd.client.config.hosts.HostConfigEntryResolver;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.compression.BuiltinCompressions;
import org.apache.sshd.common.config.keys.FilePasswordProvider;
import org.apache.sshd.common.config.keys.loader.openssh.kdf.BCryptKdfOptions;
import org.apache.sshd.common.keyprovider.KeyIdentityProvider;
import org.apache.sshd.common.signature.BuiltinSignatures;
import org.apache.sshd.common.signature.Signature;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.internal.transport.ssh.OpenSshConfigFile;
import org.eclipse.jgit.internal.transport.sshd.CachingKeyPairProvider;
import org.eclipse.jgit.internal.transport.sshd.GssApiWithMicAuthFactory;
import org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthFactory;
import org.eclipse.jgit.internal.transport.sshd.JGitServerKeyVerifier;
import org.eclipse.jgit.internal.transport.sshd.JGitSshClient;
import org.eclipse.jgit.internal.transport.sshd.JGitSshConfig;
import org.eclipse.jgit.internal.transport.sshd.JGitUserInteraction;
import org.eclipse.jgit.internal.transport.sshd.OpenSshServerKeyDatabase;
import org.eclipse.jgit.internal.transport.sshd.PasswordProviderWrapper;
import org.eclipse.jgit.internal.transport.sshd.SshdText;
import org.eclipse.jgit.internal.transport.sshd.agent.JGitSshAgentFactory;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.SshConfigStore;
import org.eclipse.jgit.transport.SshConstants;
import org.eclipse.jgit.transport.SshSessionFactory;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.sshd.agent.Connector;
import org.eclipse.jgit.transport.sshd.agent.ConnectorFactory;
import org.eclipse.jgit.util.FS;
/**
* A {@link SshSessionFactory} that uses Apache MINA sshd. Classes from Apache
* MINA sshd are kept private to avoid API evolution problems when Apache MINA
* sshd interfaces change.
*
* @since 5.2
*/
public class SshdSessionFactory extends SshSessionFactory implements Closeable {
private static final String MINA_SSHD = "mina-sshd"; //$NON-NLS-1$
private final AtomicBoolean closing = new AtomicBoolean();
private final Set<SshdSession> sessions = new HashSet<>();
private final Map<Tuple, HostConfigEntryResolver> defaultHostConfigEntryResolver = new ConcurrentHashMap<>();
private final Map<Tuple, ServerKeyDatabase> defaultServerKeyDatabase = new ConcurrentHashMap<>();
private final Map<Tuple, Iterable<KeyPair>> defaultKeys = new ConcurrentHashMap<>();
private final KeyCache keyCache;
private final ProxyDataFactory proxies;
private File sshDirectory;
private File homeDirectory;
/**
* Creates a new {@link SshdSessionFactory} without key cache and a
* {@link DefaultProxyDataFactory}.
*/
public SshdSessionFactory() {
this(null, new DefaultProxyDataFactory());
}
/**
* Creates a new {@link SshdSessionFactory} using the given {@link KeyCache}
* and {@link ProxyDataFactory}. The {@code keyCache} is used for all
* sessions created through this session factory; cached keys are destroyed
* when the session factory is {@link #close() closed}.
* <p>
* Caching ssh keys in memory for an extended period of time is generally
* considered bad practice, but there may be circumstances where using a
* {@link KeyCache} is still the right choice, for instance to avoid that a
* user gets prompted several times for the same password for the same key.
* In general, however, it is preferable <em>not</em> to use a key cache but
* to use a {@link #createKeyPasswordProvider(CredentialsProvider)
* KeyPasswordProvider} that has access to some secure storage and can save
* and retrieve passwords from there without user interaction. Another
* approach is to use an SSH agent.
* </p>
* <p>
* Note that the underlying ssh library (Apache MINA sshd) may or may not
* keep ssh keys in memory for unspecified periods of time irrespective of
* the use of a {@link KeyCache}.
* </p>
* <p>
* By default, the factory uses the {@link java.util.ServiceLoader} to find
* a {@link ConnectorFactory} for creating a {@link Connector} to connect to
* a running SSH agent. If it finds one, the SSH agent is used in publickey
* authentication. If there is none, no SSH agent will ever be contacted.
* Note that one can define {@code IdentitiesOnly yes} for a host entry in
* the {@code ~/.ssh/config} file to bypass the SSH agent in any case.
* </p>
*
* @param keyCache
* {@link KeyCache} to use for caching ssh keys, or {@code null}
* to not use a key cache
* @param proxies
* {@link ProxyDataFactory} to use, or {@code null} to not use a
* proxy database (in which case connections through proxies will
* not be possible)
*/
public SshdSessionFactory(KeyCache keyCache, ProxyDataFactory proxies) {
super();
this.keyCache = keyCache;
this.proxies = proxies;
// sshd limits the number of BCrypt KDF rounds to 255 by default.
// Decrypting such a key takes about two seconds on my machine.
// I consider this limit too low. The time increases linearly with the
// number of rounds.
BCryptKdfOptions.setMaxAllowedRounds(16384);
}
@Override
public String getType() {
return MINA_SSHD;
}
/** A simple general map key. */
private static final class Tuple {
private Object[] objects;
public Tuple(Object[] objects) {
this.objects = objects;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == Tuple.class) {
Tuple other = (Tuple) obj;
return Arrays.equals(objects, other.objects);
}
return false;
}
@Override
public int hashCode() {
return Arrays.hashCode(objects);
}
}
// We can't really use a single client. Clients need to be stopped
// properly, and we don't really know when to do that. Instead we use
// a dedicated SshClient instance per session. We need a bit of caching to
// avoid re-loading the ssh config and keys repeatedly.
@Override
public SshdSession getSession(URIish uri,
CredentialsProvider credentialsProvider, FS fs, int tms)
throws TransportException {
SshdSession session = null;
try {
session = new SshdSession(uri, () -> {
File home = getHomeDirectory();
if (home == null) {
// Always use the detected filesystem for the user home!
// It makes no sense to have different "user home"
// directories depending on what file system a repository
// is.
home = FS.DETECTED.userHome();
}
File sshDir = getSshDirectory();
if (sshDir == null) {
sshDir = new File(home, SshConstants.SSH_DIR);
}
HostConfigEntryResolver configFile = getHostConfigEntryResolver(
home, sshDir);
KeyIdentityProvider defaultKeysProvider = toKeyIdentityProvider(
getDefaultKeys(sshDir));
Supplier<KeyPasswordProvider> keyPasswordProvider = newKeyPasswordProvider(
credentialsProvider);
SshClient client = ClientBuilder.builder()
.factory(JGitSshClient::new)
.filePasswordProvider(createFilePasswordProvider(
keyPasswordProvider))
.hostConfigEntryResolver(configFile)
.serverKeyVerifier(new JGitServerKeyVerifier(
getServerKeyDatabase(home, sshDir)))
.signatureFactories(getSignatureFactories())
.compressionFactories(
new ArrayList<>(BuiltinCompressions.VALUES))
.build();
client.setUserInteraction(
new JGitUserInteraction(credentialsProvider));
client.setUserAuthFactories(getUserAuthFactories());
client.setKeyIdentityProvider(defaultKeysProvider);
ConnectorFactory connectors = getConnectorFactory();
if (connectors != null) {
client.setAgentFactory(
new JGitSshAgentFactory(connectors, home));
}
// JGit-specific things:
JGitSshClient jgitClient = (JGitSshClient) client;
jgitClient.setKeyCache(getKeyCache());
jgitClient.setCredentialsProvider(credentialsProvider);
jgitClient.setProxyDatabase(proxies);
jgitClient.setKeyPasswordProviderFactory(keyPasswordProvider);
String defaultAuths = getDefaultPreferredAuthentications();
if (defaultAuths != null) {
jgitClient.setAttribute(
JGitSshClient.PREFERRED_AUTHENTICATIONS,
defaultAuths);
}
if (home != null) {
try {
jgitClient.setAttribute(JGitSshClient.HOME_DIRECTORY,
home.getAbsoluteFile().toPath());
} catch (SecurityException | InvalidPathException e) {
// Ignore
}
}
// Other things?
return client;
});
session.addCloseListener(s -> unregister(s));
register(session);
session.connect(Duration.ofMillis(tms));
return session;
} catch (Exception e) {
unregister(session);
if (e instanceof TransportException) {
throw (TransportException) e;
}
throw new TransportException(uri, e.getMessage(), e);
}
}
@Override
public void close() {
closing.set(true);
boolean cleanKeys = false;
synchronized (this) {
cleanKeys = sessions.isEmpty();
}
if (cleanKeys) {
KeyCache cache = getKeyCache();
if (cache != null) {
cache.close();
}
}
}
private void register(SshdSession newSession) throws IOException {
if (newSession == null) {
return;
}
if (closing.get()) {
throw new IOException(SshdText.get().sshClosingDown);
}
synchronized (this) {
sessions.add(newSession);
}
}
private void unregister(SshdSession oldSession) {
boolean cleanKeys = false;
synchronized (this) {
sessions.remove(oldSession);
cleanKeys = closing.get() && sessions.isEmpty();
}
if (cleanKeys) {
KeyCache cache = getKeyCache();
if (cache != null) {
cache.close();
}
}
}
/**
* Set a global directory to use as the user's home directory
*
* @param homeDir
* to use
*/
public void setHomeDirectory(@NonNull File homeDir) {
if (homeDir.isAbsolute()) {
homeDirectory = homeDir;
} else {
homeDirectory = homeDir.getAbsoluteFile();
}
}
/**
* Retrieves the global user home directory
*
* @return the directory, or {@code null} if not set
*/
public File getHomeDirectory() {
return homeDirectory;
}
/**
* Set a global directory to use as the .ssh directory
*
* @param sshDir
* to use
*/
public void setSshDirectory(@NonNull File sshDir) {
if (sshDir.isAbsolute()) {
sshDirectory = sshDir;
} else {
sshDirectory = sshDir.getAbsoluteFile();
}
}
/**
* Retrieves the global .ssh directory
*
* @return the directory, or {@code null} if not set
*/
public File getSshDirectory() {
return sshDirectory;
}
/**
* Obtain a {@link HostConfigEntryResolver} to read the ssh config file and
* to determine host entries for connections.
*
* @param homeDir
* home directory to use for ~ replacement
* @param sshDir
* to use for looking for the config file
* @return the resolver
*/
@NonNull
private HostConfigEntryResolver getHostConfigEntryResolver(
@NonNull File homeDir, @NonNull File sshDir) {
return defaultHostConfigEntryResolver.computeIfAbsent(
new Tuple(new Object[] { homeDir, sshDir }),
t -> new JGitSshConfig(createSshConfigStore(homeDir,
getSshConfig(sshDir), getLocalUserName())));
}
/**
* 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 {@code null}.
*
* @param sshDir
* representing ~/.ssh/
* @return the file (need not exist), or {@code null} if no config file
* shall be used
* @since 5.5
*/
protected File getSshConfig(@NonNull File sshDir) {
return new File(sshDir, SshConstants.CONFIG);
}
/**
* Obtains a {@link SshConfigStore}, or {@code null} if no SSH config is to
* be used. The default implementation returns {@code null} if
* {@code configFile == null} and otherwise an OpenSSH-compatible store
* reading host entries from the given file.
*
* @param homeDir
* may be used for ~-replacements by the returned config store
* @param configFile
* to use, or {@code null} if none
* @param localUserName
* user name of the current user on the local OS
* @return A {@link SshConfigStore}, or {@code null} if none is to be used
*
* @since 5.8
*/
protected SshConfigStore createSshConfigStore(@NonNull File homeDir,
File configFile, String localUserName) {
return configFile == null ? null
: new OpenSshConfigFile(homeDir, configFile, localUserName);
}
/**
* Obtains a {@link ServerKeyDatabase} to verify server host keys. The
* default implementation returns a {@link ServerKeyDatabase} that
* recognizes the two openssh standard files {@code ~/.ssh/known_hosts} and
* {@code ~/.ssh/known_hosts2} as well as any files configured via the
* {@code UserKnownHostsFile} option in the ssh config file.
*
* @param homeDir
* home directory to use for ~ replacement
* @param sshDir
* representing ~/.ssh/
* @return the {@link ServerKeyDatabase}
* @since 5.5
*/
@NonNull
protected ServerKeyDatabase getServerKeyDatabase(@NonNull File homeDir,
@NonNull File sshDir) {
return defaultServerKeyDatabase.computeIfAbsent(
new Tuple(new Object[] { homeDir, sshDir }),
t -> createServerKeyDatabase(homeDir, sshDir));
}
/**
* Creates a {@link ServerKeyDatabase} to verify server host keys. The
* default implementation returns a {@link ServerKeyDatabase} that
* recognizes the two openssh standard files {@code ~/.ssh/known_hosts} and
* {@code ~/.ssh/known_hosts2} as well as any files configured via the
* {@code UserKnownHostsFile} option in the ssh config file.
*
* @param homeDir
* home directory to use for ~ replacement
* @param sshDir
* representing ~/.ssh/
* @return the {@link ServerKeyDatabase}
* @since 5.8
*/
@NonNull
protected ServerKeyDatabase createServerKeyDatabase(@NonNull File homeDir,
@NonNull File sshDir) {
return new OpenSshServerKeyDatabase(true,
getDefaultKnownHostsFiles(sshDir));
}
/**
* Gets a {@link ConnectorFactory}. If this returns {@code null}, SSH agents
* are not supported.
* <p>
* The default implementation uses {@link ConnectorFactory#getDefault()}
* </p>
*
* @return the factory, or {@code null} if no SSH agent support is desired
* @since 6.0
*/
protected ConnectorFactory getConnectorFactory() {
return ConnectorFactory.getDefault();
}
/**
* Gets the list of default user known hosts files. The default returns
* ~/.ssh/known_hosts and ~/.ssh/known_hosts2. The ssh config
* {@code UserKnownHostsFile} overrides this default.
*
* @param sshDir
* directory containing ssh configurations
* @return the possibly empty list of default known host file paths.
*/
@NonNull
protected List<Path> getDefaultKnownHostsFiles(@NonNull File sshDir) {
return Arrays.asList(sshDir.toPath().resolve(SshConstants.KNOWN_HOSTS),
sshDir.toPath().resolve(SshConstants.KNOWN_HOSTS + '2'));
}
/**
* Determines the default keys. The default implementation will lazy load
* the {@link #getDefaultIdentities(File) default identity files}.
* <p>
* Subclasses may override and return an {@link Iterable} of whatever keys
* are appropriate. If the returned iterable lazily loads keys, it should be
* an instance of
* {@link org.apache.sshd.common.keyprovider.AbstractResourceKeyPairProvider
* AbstractResourceKeyPairProvider} so that the session can later pass it
* the {@link #createKeyPasswordProvider(CredentialsProvider) password
* provider} wrapped as a {@link FilePasswordProvider} via
* {@link org.apache.sshd.common.keyprovider.AbstractResourceKeyPairProvider#setPasswordFinder(FilePasswordProvider)
* AbstractResourceKeyPairProvider#setPasswordFinder(FilePasswordProvider)}
* so that encrypted, password-protected keys can be loaded.
* </p>
* <p>
* The default implementation uses exactly this mechanism; class
* {@link CachingKeyPairProvider} may serve as a model for a customized
* lazy-loading {@link Iterable} implementation
* </p>
* <p>
* If the {@link Iterable} returned has the keys already pre-loaded or
* otherwise doesn't need to decrypt encrypted keys, it can be any
* {@link Iterable}, for instance a simple {@link java.util.List List}.
* </p>
*
* @param sshDir
* to look in for keys
* @return an {@link Iterable} over the default keys
* @since 5.3
*/
@NonNull
protected Iterable<KeyPair> getDefaultKeys(@NonNull File sshDir) {
List<Path> defaultIdentities = getDefaultIdentities(sshDir);
return defaultKeys.computeIfAbsent(
new Tuple(defaultIdentities.toArray(new Path[0])),
t -> new CachingKeyPairProvider(defaultIdentities,
getKeyCache()));
}
/**
* Converts an {@link Iterable} of {link KeyPair}s into a
* {@link KeyIdentityProvider}.
*
* @param keys
* to provide via the returned {@link KeyIdentityProvider}
* @return a {@link KeyIdentityProvider} that provides the given
* {@code keys}
*/
private KeyIdentityProvider toKeyIdentityProvider(Iterable<KeyPair> keys) {
if (keys instanceof KeyIdentityProvider) {
return (KeyIdentityProvider) keys;
}
return (session) -> keys;
}
/**
* 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 {@link SshConstants#DEFAULT_IDENTITIES}.
*
* @param sshDir
* the directory that represents ~/.ssh/
* @return a possibly empty list of paths containing default identities
* (private keys)
*/
@NonNull
protected List<Path> getDefaultIdentities(@NonNull File sshDir) {
return Arrays
.asList(SshConstants.DEFAULT_IDENTITIES).stream()
.map(s -> new File(sshDir, s).toPath()).filter(Files::exists)
.collect(Collectors.toList());
}
/**
* Obtains the {@link KeyCache} to use to cache loaded keys.
*
* @return the {@link KeyCache}, or {@code null} if none.
*/
protected final KeyCache getKeyCache() {
return keyCache;
}
/**
* Creates a {@link KeyPasswordProvider} for a new session.
*
* @param provider
* the {@link CredentialsProvider} to delegate to for user
* interactions
* @return a new {@link KeyPasswordProvider}, or {@code null} to use the
* global {@link KeyPasswordProviderFactory}
*/
protected KeyPasswordProvider createKeyPasswordProvider(
CredentialsProvider provider) {
return null;
}
private Supplier<KeyPasswordProvider> newKeyPasswordProvider(
CredentialsProvider credentials) {
return () -> {
KeyPasswordProvider provider = createKeyPasswordProvider(
credentials);
if (provider != null) {
return provider;
}
return KeyPasswordProviderFactory.getInstance().apply(credentials);
};
}
/**
* Creates a {@link FilePasswordProvider} for a new session.
*
* @param providerFactory
* providing the {@link KeyPasswordProvider} to delegate to
* @return a new {@link FilePasswordProvider}
*/
@NonNull
private FilePasswordProvider createFilePasswordProvider(
Supplier<KeyPasswordProvider> providerFactory) {
return new PasswordProviderWrapper(providerFactory);
}
/**
* Gets the user authentication mechanisms (or rather, factories for them).
* By default this returns gssapi-with-mic, public-key, password, and
* keyboard-interactive, in that order. The order is only significant if the
* ssh config does <em>not</em> set {@code PreferredAuthentications}; if it
* is set, the order defined there will be taken.
*
* @return the non-empty list of factories.
*/
@NonNull
private List<UserAuthFactory> getUserAuthFactories() {
// About the order of password and keyboard-interactive, see upstream
// bug https://issues.apache.org/jira/projects/SSHD/issues/SSHD-866 .
// Password auth doesn't have this problem.
return Collections.unmodifiableList(
Arrays.asList(GssApiWithMicAuthFactory.INSTANCE,
JGitPublicKeyAuthFactory.FACTORY,
UserAuthPasswordFactory.INSTANCE,
UserAuthKeyboardInteractiveFactory.INSTANCE));
}
/**
* Gets the list of default preferred authentication mechanisms. If
* {@code null} is returned the openssh default list will be in effect. If
* the ssh config defines {@code PreferredAuthentications} the value from
* the ssh config takes precedence.
*
* @return a comma-separated list of mechanism names, or {@code null} if
* none
*/
protected String getDefaultPreferredAuthentications() {
return null;
}
/**
* Apache MINA sshd 2.6.0 has removed DSA, DSA_CERT and RSA_CERT. We have to
* set it up explicitly to still allow users to connect with DSA keys.
*
* @return a list of supported signature factories
*/
@SuppressWarnings("deprecation")
private static List<NamedFactory<Signature>> getSignatureFactories() {
// @formatter:off
return Arrays.asList(
BuiltinSignatures.nistp256_cert,
BuiltinSignatures.nistp384_cert,
BuiltinSignatures.nistp521_cert,
BuiltinSignatures.ed25519_cert,
BuiltinSignatures.rsaSHA512_cert,
BuiltinSignatures.rsaSHA256_cert,
BuiltinSignatures.rsa_cert,
BuiltinSignatures.nistp256,
BuiltinSignatures.nistp384,
BuiltinSignatures.nistp521,
BuiltinSignatures.ed25519,
BuiltinSignatures.sk_ecdsa_sha2_nistp256,
BuiltinSignatures.sk_ssh_ed25519,
BuiltinSignatures.rsaSHA512,
BuiltinSignatures.rsaSHA256,
BuiltinSignatures.rsa,
BuiltinSignatures.dsa_cert,
BuiltinSignatures.dsa);
// @formatter:on
}
}
|