Created
February 18, 2018 17:36
-
-
Save onetwopunch/c92103d149ada1c0bd4fbe5fcc6a46cd to your computer and use it in GitHub Desktop.
IAM SSH Authentication for use with AuthorizedKeysCommand
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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