1

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Fahad Siddiqui
  • 1,829
  • 1
  • 19
  • 41

1 Answers1

3

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.

Community
  • 1
  • 1
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992