Java JSch:hdfs上存储的私钥的附加性

Java JSch:hdfs上存储的私钥的附加性,java,hadoop,hdfs,sftp,jsch,Java,Hadoop,Hdfs,Sftp,Jsch,我需要从hadoop集群连接到sftp服务器。我想知道是否有办法从存储在hdfs中的私钥加载标识。实际上,JSch对象似乎只接受本地路径: try { String privateKeyPath = "hdfs://namenode:8020/path/to/privatekey"; // need this one to be an hdfs path JSch jsch = new JSch(); jsch.addIdentity(privateKeyPath);

我需要从hadoop集群连接到sftp服务器。我想知道是否有办法从存储在hdfs中的私钥加载标识。实际上,JSch对象似乎只接受本地路径:

try {
    String privateKeyPath = "hdfs://namenode:8020/path/to/privatekey";  // need this one to be an hdfs path
    JSch jsch = new JSch();

    jsch.addIdentity(privateKeyPath);

    // [..]
}
catch (Exception ex) {
    // [..]
}

有什么想法吗?

感谢@Martin Prikryl answer,解决方法如下:

// Get sftp private/public key for JSch identity
FSDataInputStream fis = fs.open(privateKeyPath);
byte[] privateKeyBytes = IOUtils.toByteArray(fis);

fis = fs.open(publicKeyPath);
byte[] publicKeyBytes = IOUtils.toByteArray(fis);
fis.close();

JSch jsch = new JSch();
String idName = "ksftp";
byte[] passphrase = null;  
jsch.addIdentity(idName, privateKeyBytes, publicKeyBytes, passphrase);