I am wanting to use VFS2 to connect to an SFTP server using a private key.
However, the application will be running using Java EE on an application server; and so I don't want to store the private key in a file - I want to store it (encrypted) in a database instead; and then read the key and use it to connect.
However, all the instructions I can find (e.g. How to use apache vfs2 for sftp with public-private-key and without password) use a private key file
, and apache VFS2 seems to require a file rather than a string in its identity provider object. (e.g. IdentityInfo myIdentityInfo = new IdentityInfo(new File(openSSHPrivateKey));
)
I guess I could read the DB, save to a temporary file, then delete the temp file afterwards, but ideally I wouldn't use the local file system on the application server. Is there a way around this?