Thread Net::SSH::Perl Login ohne Prompt (3 answers)
Opened by _B_ at 2005-11-20 03:02

_B_
 2005-11-20 19:34
#36935 #36935
User since
2005-11-20
3 Artikel
BenutzerIn
[default_avatar]
bin einige schritte weiter.

der alte fehler lag nicht am skript, sondern an der config des sshd auf der remote maschine ("PasswordAuthentication no" in sshd_config). das skript (s.u.) läuft also durch, aber: die reihenfolge der "authentication methods" will sich nicht ändern lassen. diese ist defaultmässig "hostbased,publickey,keyboard-interactive,password". das hat zur folge, dass 3 prompts zur eingabe des passwortes erscheinen. in diese kann ich "test, wurst, sonstiges" eingeben (also nix passendes), sie muss nur durchlaufen werden. die letzte (password) klappt dann und das skript tut.

wie kann ich die reihenfolge ändern? die doku des moduls sagt, dass man im hash %config "options => ..." angeben kann, das klappt aber nicht. es sollte auch gehen, die config über die normale ssh_config zu machen. ändert aber auch nix. mein plan ist es, die option "ChallengeResponseAuthentication no" zu setzen. das ist die method laut debug ausgabe.

:ratlos

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl

# caution: this script logs into remote machine and execute commands.
# for the script to work fine, the sshd on the remote machine must accept
# password-based authentication. this is controlled with the parameter
# "PasswordAuthentication yes" in sshd_config.

use warnings;
use strict;

use Net::SSH::Perl;

my $host = '192.168.100.21';
my $port = '22';
my $user = 'dummy';
my $pass = 'dummy';

my %config = (
port => $port,
debug => 1,
interactive => 0,
options => ["ChallengeResponseAuthentication no"]
);

my $ssh = Net::SSH::Perl->new($host, %config);
$ssh->login($user, $pass);

my ($out, $err, $exit) = $ssh->cmd("uname -a");
print "$out\n";
if ($out =~ /^Darwin/) {
($out, $err, $exit) = $ssh->cmd("sw_vers");
print "$out\n";
}

View full thread Net::SSH::Perl Login ohne Prompt