Rex-LibSSH
view release on metacpan or search on metacpan
t/01-rex-integration.t view on Meta::CPAN
use Rex -feature => ['1.4'];
use Rex::Group::Entry::Server;
use Rex::Commands::Run;
use Rex::Commands::Fs;
use Rex::Commands::File;
use Rex::Config;
set connection => 'LibSSH';
Rex::Config->set_user( scalar getpwuid($<) );
Rex::Config->set_private_key( $srv->client_key );
Rex::Config->set_public_key( $srv->client_key . '.pub' );
Rex::connect(
server => $srv->host,
port => $srv->port,
user => scalar( getpwuid($<) ),
private_key => $srv->client_key,
public_key => $srv->client_key . '.pub',
auth_type => 'key',
);
# --- run ---
my $out = run 'echo hello';
chomp $out;
is $out, 'hello', 'run echo works';
t/lib/TestSSHD.pm view on Meta::CPAN
or return undef;
system('ssh-keygen', '-t', 'ed25519', '-N', '', '-f', "$dir/client_key", '-q') == 0
or return undef;
system('cp', "$dir/client_key.pub", "$dir/authorized_keys") == 0
or return undef;
chmod 0600, "$dir/authorized_keys";
my $port = _free_port() or return undef;
my $user = getpwuid($<);
my $cfg = "$dir/sshd_config";
open my $fh, '>', $cfg or return undef;
print $fh <<"CONFIG";
Port $port
HostKey $dir/host_key
AuthorizedKeysFile $dir/authorized_keys
PidFile $dir/sshd.pid
LogLevel ERROR
StrictModes no
( run in 1.518 second using v1.01-cache-2.11-cpan-39bf76dae61 )