I am trying to use JSch to SFTP a file to a remote location. Per this article, when you do SFTP, you can use either a private key or a password for authentication. We are doing private-key authentication.
JSch has a method called addIdentity()
where you register your private key, but it also takes a password:
void addIdentity(String prvkey, String passphrase)
Adds an identity to be used for public-key authentication.
Does this refer to the private key also being password-protected itself? What if the private key has no password protection?
Yes, that's a passphrase (not a password) used to encrypt the private key file.
If your private key is not encrypted, use the overload that does not take the passphrase
.
public void addIdentity(String prvkey)