I'm setting up SFTP delivery of files to a server using public/private keys generated with ssh-keygen on mac. The private key I generated looks different from other private keys already in the codebase (it doesn't have headers and it's an "OPENSSH PRIVATE KEY" instead of "RSA PRIVATE KEY".
My java FtpUtil is throwing invalid privatekey
error.
Is this because the key I generated is not correctly formatted in some way? Is there a way to change this private key to use headers?
This is what other private keys in the codebase look like:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,E26BE59A622AEDE6A899FE18AD369AA0
<key text>
-----END RSA PRIVATE KEY-----
This is what my private key looks like:
-----BEGIN OPENSSH PRIVATE KEY-----
<key text>
-----END OPENSSH PRIVATE KEY-----
I'm getting the following exception thrown:
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@5c0f79f0
at com.jcraft.jsch.KeyPair.load(KeyPair.java:664)
at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:46)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:442)
at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.initJschSession(DefaultSftpSessionFactory.java:410)
at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:385)
... 46 more