-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support EC2 instance connect #39
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! 🎉
Since additional setup is required to use EC2 Instance Connect, we'll also want to update the documentation to point at the AWS docs re: security group guidance and IAM permissions. (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed response. After thinking about it a bit more, it might make more sense to have the userdata structure look more like:
{
"ssh":{
"authorized-keys":[
"ssh-rsa EXAMPLEAUTHORIZEDPUBLICKEYHERE my-key-pair"
],
"trusted-user-ca-keys":[
"ssh-rsa EXAMPLETRUSTEDCAPUBLICKEYHERE [email protected]"
],
"authorized-keys-command": "...",
"authorized-keys-command-user": "..."
}
You could parse the authorized keys command and user and output them to their own config under /etc/ssh/sshd_config.d/
. If those values are for EC2 Instance Connect you could conditionally trigger the symlink and key harvest logic you have in the current PR. We are going to double-check on our end to see if the key harvest logic is required or whether it is safe to omit. Is this something you would be open to implementing? Or would you be more comfortable with us working on it?
I've verified that |
@jpculp Thanks for your review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the quick update @samjo-nyang! I think this is very close.
I'm afraid I led you astray by suggesting the switch to a separate config file. After some testing on my end, it seems that the OpenSSH in the admin container does not yet support the Include
directive in the sshd_config
file itself. It might be better to just append to sshd_config
directly. You could have a variable like SSHD_CONFIG_FILE variable pointing to "${SSHD_CONFIG_DIR}/sshd_config"
.
@jpculp Updated! (and also force-pushed) |
I currently get
I understand the Include problem is mentioned and fixed above, but the userdata problem would remain. My reading is that this happens because setting authorized-keys-command and authorized-keys-command-user does not increment available_auth_methods |
@willthames I just re-ordered the statements and increase available_auth_methods when use_eic=1. It should work now. |
Thanks @samjo-nyang - I'll give it a go! |
This works great for me now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me!
Also, thank you for testing this out @willthames!
Force-pushed (remove use_eic=1 condition and symlink the host keys for all cases) |
**Issue number: #38 **
Description of changes:
Testing done:
This patch is currently used in our internal Kubernetes cluster.
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.