VM::EC...T::keys(3pm)
π VM::EC2::REST::keys π
hey bestie!! you found the page for VM::EC2::REST::keys (that's the 3pm one, perl's own little corner of the internet) and honestly? it's a whole vibe. this is the module that handles your ssh key pairs on AWS, and it's lowkey iconic. let's get into it π«Ά
β¨ NAME β¨
VM::EC2::REST::keys β Manipulate ssh key pairs πβ¨
πΈ SYNOPSIS πΈ
use VM::EC2 ':standard';
that's it. that's the whole synopsis. we love a minimal queen π
π METHODS π
β Implemented
these ones are real, they exist, they ate:
DescribeKeyPairsCreateKeyPairImportKeyPairDeleteKeyPair
π Unimplemented
- (none)
not a single one missing, we're fully booked and fully slaying πβ¨
These methods let you manipulate ssh key pairs.
π¦ @keys = $ec2->describe_key_pairs(@names);
π¦ @keys = $ec2->describe_key_pairs(\%filters);
π¦ @keys = $ec2->describe_key_pairs(-key_name => \@names, -filter => \%filters);
Searches for ssh key pairs matching the filters you hand over, and gives you back a whole series of VM::EC2::KeyPair objects. it's giving keypair buffet π
Optional arguments, bestie:
-key_nameβ a single key name, or an arrayref holding a list of names-filterβ filter on tags and other attributes
The full list of key filters lives right here: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html π
π $key = $ec2->create_key_pair($name)
Makes you a shiny new key pair with the name you give it (required, no skipping). If that key pair already exists, you get back undef β sorry bestie, no duplicates allowed π. The contents of the new keypair, including the PEM-encoded private key, are contained inside the returned VM::EC2::KeyPair object, like this:
my $key = $ec2->create_key_pair('My Keypair');
if ($key) {
print $key->fingerprint,"\n";
print $key->privateKey,"\n";
}
look at her go ππ
π§ $key = $ec2->import_key_pair($name,$public_key)
π§ $key = $ec2->import_key_pair(-key_name => $name, -public_key_material => $public_key)
Imports a preexisting public key into AWS under whatever name you specify. If it works, you get a VM::EC2::KeyPair back. Important: the public key must be an RSA key with a length of 1024, 2048 or 4096. those are the only sizes invited to the party π
You can call this method two ways: with two unnamed arguments (the key name and the public key material), or in named-argument form with these names:
-key_nameβ desired name for the imported key pair (required)-nameβ shorter version of-key_name-public_key_materialβ public key data (required)-public_keyβ shorter version of the above
This example uses Net::SSH::Perl::Key to generate a new keypair, then uploads the public key to Amazon:
use Net::SSH::Perl::Key;
my $newkey = Net::SSH::Perl::Key->keygen('RSA',1024);
$newkey->write_private('.ssh/MyKeypair.rsa'); # save private parts
my $key = $ec2->import_key_pair('My Keypair' => $newkey->dump_public)
or die $ec2->error;
print "My Keypair added with fingerprint ",$key->fingerprint,"\n";
Several different formats are accepted for the key, including SSH "authorized_keys" format (the kind generated by ssh-keygen and Net::SSH::Perl::Key), the SSH public keys format, and DER format. You do not need to base64-encode the key or do any other pre-processing β just hand it over as-is, she'll take it from there π«Ά
β οΈ heads up bestie: the algorithm Amazon uses to calculate its key fingerprints is not the same one the ssh library uses. so do not try to compare the key fingerprints returned by Amazon to the ones produced byssh-keygenorNet::SSH::Perl::Key. they will not match and you will be confused for no reason π
π $result = $ec2->delete_key_pair($name)
Deletes the key pair with the name you give it (required). Returns true if it worked. bye bestie πβ¨
π SEE ALSO π
VM::EC2
π AUTHOR π
Lincoln Stein <lincoln.stein@gmail.com>.
Copyright (c) 2011 Ontario Institute for Cancer Research
This package and its accompanying libraries is free software; you can redistribute it and/or modify it under the terms of the GPL (either version 1, or at your option, any later version) or the Artistic License 2.0. Refer to LICENSE for the full license text. In addition, please see DISCLAIMER.txt for disclaimers of warranty.
and that's the whole page, bestie!! π this was generated by perl v5.38.2 on 2024-08-10, and honestly the docs for VM::EC2::REST::keys ate and left no crumbs π mwah, go make some key pairs, you've got this π¦β¨
π¦ where this page comes from
- debian trixie: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- ubuntu resolute: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- ubuntu stonking: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms