properties.setHost(hostname);
properties.setPrefPublicKey("ssh-dss");
// Connect to the host
ssh.connect(properties);
// Create a password authentication instance
PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
// Get the users name
System.out.print("Username? ");
// Read the password
String username = reader.readLine();
pwd.setUsername(username);
// Get the password
System.out.print("Password? ");
String password = reader.readLine();
pwd.setPassword(password);
// Try the authentication
int result = ssh.authenticate(pwd);
// Evaluate the result
if (result == AuthenticationProtocolState.COMPLETE) {
// The connection is authenticated we can now do some real work!