Class GitSshServer
java.lang.Object
org.apache.maven.scm.provider.git.GitSshServer
Local Git SSH server for testing purposes.
It acts on top of an existing repository root directory.
It uses Apache MINA SSHD for the SSH server implementation.
The server generates a key pair during initialization and accepts connections using the private key which can be
extracted via writePrivateKeyAsPkcs8(Path, String).
Alternatively one may use a custom key pair and add the public key using addPublicKey(PublicKey).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPublicKey(PublicKey publicKey) intgetPort()voidvoidstop()voidwritePrivateKeyAsPkcs8(Path file, String passphrase) Writes a private key which is accepted by this server to the specified file in PKCS8 format.
-
Field Details
-
sshServer
protected final org.apache.sshd.server.SshServer sshServer -
keyPair
-
acceptedPublicKeys
-
-
Constructor Details
-
GitSshServer
- Throws:
GeneralSecurityException
-
-
Method Details
-
writePrivateKeyAsPkcs8
public void writePrivateKeyAsPkcs8(Path file, String passphrase) throws IOException, GeneralSecurityException Writes a private key which is accepted by this server to the specified file in PKCS8 format. If a passphrase is provided, the key will be encrypted using OpenSSH's format. If no passphrase is provided, the key will be written as an unencrypted PKCS8 private key. For the same server instance the private key is always the same, so it can be reused.- Parameters:
file- the file to write the private key topassphrase- the passphrase for encryption, or null for unencrypted- Throws:
GeneralSecurityException- if a security error occursIOException- if an I/O error occurs
-
addPublicKey
-
getPort
public int getPort() -
start
- Throws:
IOException
-
stop
- Throws:
IOException
-