Ich hab ein dickes Problem und hoffe
- IRGENDJEMAND hat davon Ahnung
- Ich bin im richtigen Thread.
Also: Kurze Problembeschreibung:
Ich will mich auf einer Unixmaschine mit SSH und einem Key anmelden. (id_rsa)
Dazu habe ich bisher folgenden Code:
[...]
ssh = new SshClient();
ssh.setSocketTimeout(1000);
SshConnectionProperties properties = new SshConnectionProperties();
properties.setHost(s.IP);
properties.setUsername(s.LoginName);
// Connect to the host
try {
// Mit Passwort:
// ssh.connect(properties);
// PasswordAuthenticationClient pk = new PasswordAuthenticationClient();
// pk.setUsername(s.LoginName);
// pk.setPassword(s.Passwort);
// Per SSH
HostKeyVerification ver = new SinkHostKeyVerification(s.IP);
ssh.connect(properties,ver);
PublicKeyAuthenticationClient pk = new PublicKeyAuthenticationClient();
pk.setUsername(s.LoginName);
// Private Key File
SshPrivateKeyFile file = SshPrivateKeyFile.parse(new File("key\_ppk.ppk"));
SshPrivateKey key = file.toPrivateKey("");
pk.setKey(key);
if (ssh.authenticate(pk) == AuthenticationProtocolState.COMPLETE) {
System.out.println("drin");
}
Mit der Auskommentierten Passwortabfrage geht es, aber nicht mit dem SSH-Key…
Die API dazu ist leider der größte Rotz und auch Google lässt sich nix brauchbares entlocken…
Also schon mal THX für jede Antwort!