SSHサーバが受け付け可能な認証方法を列挙する
もっとスマートな方法ないかしらん。
#!/usr/bin/env perl use strict; use warnings; use Net::SSH::Perl; use Net::SSH::Perl::AuthMgr; QUICK_HACK: { package Net::SSH::Perl::AuthMgr; no warnings 'redefine', 'once'; *auth_failure = sub { my $amgr = shift; my($packet) = @_; my $ssh = $amgr->{ssh}; my $authlist = $packet->get_str; $amgr->{_done} = 1; $amgr->{__authlist} = [ split /,/, $authlist ]; }; *authlist = sub { my $amgr = shift; $amgr->authenticate; return @{ $amgr->{__authlist} }; }; } my $host = $ARGV[0]; my $ssh = Net::SSH::Perl->new($host, compression => 0, protocol => 2, ); Net::SSH::Perl::Kex->new($ssh)->exchange; my $amgr = Net::SSH::Perl::AuthMgr->new($ssh); my @authlist = $amgr->authlist; print join("\n", @authlist), "\n";
$ probe-ssh-auth foo.example.org publickey keyboard-interactive $ probe-ssh-auth bar.example.org publickey password keyboard-interactive