my $SSH2 = Net::SSH2 -> new(); my $Server_Adresse = "XXX.XX.XX.XX"; my $Nutzer = "root"; my $PW = "XXXXXXXX"; # $SSH2 -> connect( $Server_Adresse ) or die "Keine Verbindung zu Host - Adresse $@" , "\n"; # $SSH2 -> auth_password( $Nutzer , $PW ) or die "Fehler bei der Anmeldung $@" , "\n"; # -------------------------------------------------------------------------------------------- print "\n"; my $SSH2_Authentifizierung; if ( $SSH2 -> connect( "$Server_Adresse" ) ) { $SSH2_Authentifizierung = $SSH2 -> auth_publickey ( 'root' , '/root/.ssh/id_rsa.pub' , '/root/.ssh/id_rsa' , '' ); } if ( $SSH2_Authentifizierung && $SSH2 -> auth_ok ) { print "Success"; } else { print join ", " , $SSH2 -> error; }