Reputation: 1849
I am using JSch library to create and manage "secure FTP" connection in Scala. Can someone show example using public/private key in configuration of session
?
Right now I'm doing this
session.setConfig("StrictHostKeyChecking", "no")
This exposes the secure connection for unauthorized hits over maintained session which, obviously, I don't want for security reasons.
How can I set private/public key mechanism in my code here.
Upvotes: 1
Views: 668
Reputation: 202534
The StrictHostKeyChecking
has nothing to do with private/public key authentication. It's about host key verification. Though you are right that you should not set the option to no
.
See JSch SFTP security with session.setConfig("StrictHostKeyChecking", "no");
For the actual public/private key authentication, see Can we use JSch for SSH key-based communication?
Though note that the accepted answer wrongly sets the StrictHostKeyChecking
to no
. So do not copy that part.
Upvotes: 3