Public key authentication

Top  Previous  Next

In addition to username/password authentication, the Sftp class supports another authentication method known as public key authentication. Using this method you can authenticate with the SSH server using a username, private key and optional pass phrase to protect the private key. Please consult you SSH server documentation for how to generate keys and enable public key authentication.

 

Example

 

// define path of private key    

File privateKey = new File("c:/keys/ssh/id_dsa");

 

// create SshParameters instance using public key authentication

SshParameters params = new SshParameters(hostname,username,privateKey);

 

// create new Sftp instance

Sftp sftp = new Sftp(params);

 

// connect and authenticate

sftp.connect();





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC