private static CipherParameters getSSHPrivateKey(InputStream sshPrivateKeyIn, String srcName)
			throws InvalidKeyException, IOException {

		StringBuffer keyBuf = new StringBuffer();
		try (BufferedReader r = new BufferedReader(new InputStreamReader(sshPrivateKeyIn))) {
			boolean checkKeyFormat = true;
			String line;
			while ((line = r.readLine()) != null) {
				if (checkKeyFormat) {
					if (!line.startsWith("-----BEGIN ") || line.indexOf(" KEY-----") < 0) {
						throw new InvalidKeyException("Invalid SSH Private Key");
					}
					if (!line.startsWith("-----BEGIN RSA PRIVATE KEY-----") &&
						!line.startsWith("-----BEGIN DSA PRIVATE KEY-----")) {
						Msg.error(SSHKeyManager.class,
							"Unsupported SSH Key Format (see svrREADME.html)");
						throw new IOException("Unsupported SSH Private Key");
					}
					checkKeyFormat = false;
				}
				if (keyBuf.length() != 0) {
					keyBuf.append('\n');
				}
				keyBuf.append(line);
			}
		}

		char[] password = null;
		try (Reader r = new StringReader(keyBuf.toString())) {

			PEMParser pemParser = new PEMParser(r);
			Object object = pemParser.readObject();

			PrivateKeyInfo privateKeyInfo;
			if (object instanceof PEMEncryptedKeyPair) {

				password = passwordProvider.getKeyStorePassword(srcName, false);
				if (password == null) {
					throw new IOException("Password required to open SSH private keystore");
				}

				// Encrypted key - we will use provided password
				PEMEncryptedKeyPair ckp = (PEMEncryptedKeyPair) object;
				PEMDecryptorProvider decProv =
					new JcePEMDecryptorProviderBuilder().build(password);
				privateKeyInfo = ckp.decryptKeyPair(decProv).getPrivateKeyInfo();
			}
			else {
				// Unencrypted key - no password needed
				PEMKeyPair ukp = (PEMKeyPair) object;
				privateKeyInfo = ukp.getPrivateKeyInfo();
			}
			return PrivateKeyFactory.createKey(privateKeyInfo);
		}
		finally {
			if (password != null) {
				Arrays.fill(password, (char) 0);
			}
		}
	}
Return the SSH private key corresponding to the specified key input stream.
If the specified key is encrypted the currently installed password
provider will be used to obtain the decrypt password.
@param sshPrivateKeyIn private ssh key resource input stream
@return private key cipher parameters ({@link RSAKeyParameters} or {@link DSAKeyParameters})
@throws FileNotFoundException key file not found
@throws IOException if key file not found or key parse failed
@throws InvalidKeyException if key is not an SSH private key (i.e., PEM format)
Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/remote/security/SSHKeyManager.java