Conversation
50e6e79 to
4b8ff61
Compare
Signed-off-by: Pedro Tôrres <pedro.torres@incognia.com>
|
Steps to make it work on an EC2 Mac instance:
wget https://github.com/inloco/aws-ec2-instance-connect-config/archive/HEAD.zip
unzip ./HEAD.zip
rm ./HEAD.zip
cp ./aws-ec2-instance-connect-config-*/src/bin/* /opt/aws/bin
sed -ri 's|#(AuthorizedKeysCommand) .+|\1 /opt/aws/bin/eic_run_authorized_keys %u %f|g' /private/etc/ssh/sshd_config
sed -ri 's/#(AuthorizedKeysCommandUser) .+/\1 ec2-instance-connect/g' /private/etc/ssh/sshd_config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>com.amazon.aws.ec2-instance-connect</string>
<key>Program</key>
<string>/opt/aws/bin/eic_harvest_hostkeys</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist> |
Could we please instead use This way it will work on Linux, MacOS, NixOS and all the BSDs |
|
That would be equivalent to not specifying the path: Either way, it seems AWS is not open to contributions here. I even talked with the PM on AWS who is responsible for the Mac Instances on EC2, and he thanked me for the patch and said he would have someone take a look, but no one ever did. |
Issue #, if available:
#33
Description of changes:
Remove system UUID check as it is specific for Linux and Windows instances. Mac instances don't have the EC2 prefix on their UUID. A platform independent way of checking if the machine is indeed is an EC2 Instance is by Inspecting the instance identity document (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html#inspect-document), already used by the script on a latter step. It's important to notice I did not implement the signature verification of the document as I considered it would be overkill.
Change canonical paths of
grep,mktemp,sed, andtouchfrom/binto/usr/bin. This change is also compatible with Linux.Change canonical paths of
test/usr/binto/bin`. This change is also compatible with Linux.Use
/tmpinstead of/dev/shm, available on both Linux and macOS.Change regular expressions to make them compatible with macOS versions of
findandsed. New expressions are still compatible with Linux.When running on macOS, generate a CA bundle with
security find-certificateand set is asca_pathinstead of using/etc/ssl/certs.Extract
sha256sumanddate -udto functions that handle each operation in specific ways for Linux and macOS.Use existing
sha256function when calculating hashes.Rewrite sed expressions to be compatible with BSD and GNU versions of sed.
Replace
timeout 5with& /bin/sleep 5; /bin/kill -KILL $! 2> /dev/null || :(http://blog.mediatribe.net/en/node/72/index.html) as macOS doesn't have it available. This can also be used on Linux.Replace
grep -oPwithsed -Ento getaccountIdfrom JSON, using the same expression used to getAccessKeyId,SecretAccessKey, andTokenfrom JSON.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.