VM::EC...T::keys(3pm)

πŸ“¦
version 1.28 Β· 7 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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:

  • DescribeKeyPairs
  • CreateKeyPair
  • ImportKeyPair
  • DeleteKeyPair

πŸ™ˆ 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 by ssh-keygen or Net::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