Public key authentication

Top  Previous  Next

Public key authentication is a method of authenticating with an SSH server using a private key known only to the user establishing the connection and a public key known to the server. Public key authentication provides an extra level of security above authenticating using only a username and password.

 

Before authenticating using public key authentication you must first create a key pair, install the public key on your server and save the private key locally for use in authentication. For information on creating and installing keys please consult your SSH server documentation. Keys generated in either OpenSSH or SECSH formats are supported.

 

Example

 

String hostname = "ssh.myhost.com";

String username = "jsmith";

 

// define path of private key    

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

 

// create com.jscape.inet.ssh.util.SshParameters instance using public key authentication

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

 

// create new Ssh instance

Ssh ssh = new Ssh(params);

 

Note

 

Private keys may optionally be password protected. To authenticate using a password protected private key simply use the SshParameters constructor that takes both private key and a password as arguments.





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

© 2021 JSCAPE LLC