Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

Commit 17749fb

Browse files
mvanbaakmichaelwittig
authored andcommitted
When checking the ssh key, make sure we transform the "save" username back to the original IAM "unsave" username. Fixes upstream issue #27 (#29)
1 parent 17fbabc commit 17749fb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

authorized_keys_command.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ if [ -z "$1" ]; then
44
exit 1
55
fi
66

7-
SaveUserName="$1"
8-
SaveUserName=${SaveUserName//"+"/".plus."}
9-
SaveUserName=${SaveUserName//"="/".equal."}
10-
SaveUserName=${SaveUserName//","/".comma."}
11-
SaveUserName=${SaveUserName//"@"/".at."}
7+
UnsaveUserName="$1"
8+
UnsaveUserName=${UnsaveUserName//".plus."/"+"}
9+
UnsaveUserName=${UnsaveUserName//".equal."/"="}
10+
UnsaveUserName=${UnsaveUserName//".comma."/","}
11+
UnsaveUserName=${UnsaveUserName//".at."/"@"}
1212

13-
aws iam list-ssh-public-keys --user-name "$SaveUserName" --query "SSHPublicKeys[?Status == 'Active'].[SSHPublicKeyId]" --output text | while read KeyId; do
14-
aws iam get-ssh-public-key --user-name "$SaveUserName" --ssh-public-key-id "$KeyId" --encoding SSH --query "SSHPublicKey.SSHPublicKeyBody" --output text
13+
aws iam list-ssh-public-keys --user-name "$UnsaveUserName" --query "SSHPublicKeys[?Status == 'Active'].[SSHPublicKeyId]" --output text | while read KeyId; do
14+
aws iam get-ssh-public-key --user-name "$UnsaveUserName" --ssh-public-key-id "$KeyId" --encoding SSH --query "SSHPublicKey.SSHPublicKeyBody" --output text
1515
done

0 commit comments

Comments
 (0)