I have the contents of the key pair file for SFTP as a string. I need to use JSch to add the contents, but addIdentity
only accepts a file path. Is there anyway I can do this?
I see that the KeyPair
class has a method -
KeyPair load(JSch jsch, byte[] bytes, byte[] bytes1)
I'm not sure what this does.
There is an
addIdentity
overload that takes the key from a buffer:See also Java SFTP client that takes private key as a string.
For an example of implementation, see JSch: addIdentity from private key stored on hdfs.