Public key authentication |
In addition to username/password authentication, the Scp 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 Scp instance Scp scp = new Scp(params);
// connect and authenticate scp.connect();
|