mirror of
https://github.com/ovh/the-bastion.git
synced 2025-01-09 08:47:50 +08:00
39 lines
1.2 KiB
Perl
Executable file
39 lines
1.2 KiB
Perl
Executable file
#! /usr/bin/env perl
|
|
# vim: set filetype=perl ts=4 sw=4 sts=4 et:
|
|
use common::sense;
|
|
|
|
use File::Basename;
|
|
use lib dirname(__FILE__) . '/../../../lib/perl';
|
|
use OVH::Result;
|
|
use OVH::Bastion;
|
|
use OVH::Bastion::Plugin qw( :DEFAULT help );
|
|
|
|
my $remainingOptions = OVH::Bastion::Plugin::begin(
|
|
argv => \@ARGV,
|
|
header => "Here are the public keys that allow you to connect to the bastion",
|
|
helptext => <<'EOF',
|
|
List the public ingress keys of your account
|
|
|
|
Usage: --osh SCRIPT_NAME
|
|
|
|
The keys listed are the public ingress SSH keys tied to your account.
|
|
Their private counterpart should be detained only by you, and used
|
|
to authenticate yourself to this bastion.
|
|
EOF
|
|
);
|
|
|
|
my $fnret;
|
|
|
|
$fnret = OVH::Bastion::get_authorized_keys_from_file(file => "$HOME/.ssh/authorized_keys2", includeInvalid => 1);
|
|
$fnret or osh_exit $fnret;
|
|
|
|
my @result;
|
|
foreach my $key (@{$fnret->value || []}) {
|
|
OVH::Bastion::print_public_key(key => $key, id => $key->{'index'}, err => $key->{'err'});
|
|
$key->{'validity'} = delete $key->{'err'};
|
|
$key->{'id'} = delete $key->{'index'};
|
|
$key->{'from_list'} = delete $key->{'fromList'};
|
|
push @result, $key;
|
|
}
|
|
|
|
osh_ok({keys => \@result, account => $self});
|