private static String getRSAPrivateKey(KeyPair rsaKeyPair) {
		RSAPrivateKey privateKey = (RSAPrivateKey) rsaKeyPair.getPrivate();
		RSAPrivateCrtKey privateCrtKey = (RSAPrivateCrtKey) privateKey;
		RSAPublicKey publicKey = (RSAPublicKey) rsaKeyPair.getPublic();

		byte[] nArray = privateKey.getModulus().toByteArray();
		byte[] eArray = publicKey.getPublicExponent().toByteArray();
		byte[] dArray = privateKey.getPrivateExponent().toByteArray();
		byte[] pArray = privateCrtKey.getPrimeP().toByteArray();
		byte[] qArray = privateCrtKey.getPrimeQ().toByteArray();
		byte[] epArray = privateCrtKey.getPrimeExponentP().toByteArray();
		byte[] eqArray = privateCrtKey.getPrimeExponentQ().toByteArray();
		byte[] cArray = privateCrtKey.getCrtCoefficient().toByteArray();

		int contentLength = 11 + getEncodedLength(nArray) + getEncodedLength(eArray) +
			getEncodedLength(dArray) + getEncodedLength(pArray) + getEncodedLength(qArray) +
			getEncodedLength(epArray) + getEncodedLength(eqArray) + getEncodedLength(cArray);

		ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
		bytesOut.write(0x30);
		writeEncodedValue(contentLength, bytesOut);
		writeEncoded(new byte[1], bytesOut); // zero
		writeEncoded(nArray, bytesOut);
		writeEncoded(eArray, bytesOut);
		writeEncoded(dArray, bytesOut);
		writeEncoded(pArray, bytesOut);
		writeEncoded(qArray, bytesOut);
		writeEncoded(epArray, bytesOut);
		writeEncoded(eqArray, bytesOut);
		writeEncoded(cArray, bytesOut);
		byte[] privateKeyBytes = bytesOut.toByteArray();

		byte[] base64data = Base64.getEncoder().encodeToString(privateKeyBytes).getBytes();

		StringBuilder rsaKeyOut = new StringBuilder();

		rsaKeyOut.append("-----BEGIN RSA PRIVATE KEY-----\n");
		int cnt = 0;
		while (cnt < base64data.length) {
			int len = Math.min(64, base64data.length - cnt);
			rsaKeyOut.append(new String(base64data, cnt, len));
			rsaKeyOut.append('\n');
			cnt += len;
		}
		rsaKeyOut.append("-----END RSA PRIVATE KEY-----\n");

		return rsaKeyOut.toString();
	}
Generate SSH RSA private key file content in PEM format
@param rsaKeyPair SSH public/private key pair
@return SSH private key file content string in PEM format
Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/server/remote/SSHKeyUtil.java