Skip to content

Instantly share code, notes, and snippets.

@onetwopunch
Created February 18, 2018 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onetwopunch/c92103d149ada1c0bd4fbe5fcc6a46cd to your computer and use it in GitHub Desktop.
Save onetwopunch/c92103d149ada1c0bd4fbe5fcc6a46cd to your computer and use it in GitHub Desktop.
IAM SSH Authentication for use with AuthorizedKeysCommand
#!/usr/bin/env ruby
require 'aws-sdk-iam'
client = Aws::IAM::Client.new
resp = client.list_ssh_public_keys(user_name: ARGV[1], max_items: 1)
pub_key_id = resp.ssh_public_keys.first.ssh_public_key_id
puts client.get_ssh_public_key({
user_name: ARGV[1],
ssh_public_key_id: pub_key_id,
encoding: "SSH"
}).ssh_public_key_body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment