Skip to content
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

patching authorizedKeysCommand to use /etc/ssl/certs/ca-bundle.crt #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/ec2-instance-connect.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
};
services.openssh = {
authorizedKeysCommandUser = "ec2-instance-connect";
authorizedKeysCommand = "/etc/ssh/eic_run_authorized_keys %u %f";
authorizedKeysCommand = "/etc/ssh/aws-ec2-instance-connect %u %f";
};
}
85 changes: 51 additions & 34 deletions packages/ec2-instance-connect.nix
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
{ stdenv
, fetchFromGitHub
, buildFHSEnv
, coreutils
, curl
, openssh
, cacert
, gnugrep
, util-linux
, openssl
, gawk
, gnused
{
stdenvNoCC,
fetchFromGitHub,
buildFHSEnv,
coreutils,
curl,
openssh,
cacert,
gnugrep,
util-linux,
openssl,
gawk,
gnused,
}:
# TODO: This currently fails with exit code 1 and no helpful error message.
# TODO(#8): This currently fails with exit code 1 and no helpful error message
let
src = fetchFromGitHub {
# https://github.com/aws/aws-ec2-instance-connect-config
owner = "aws";
repo = "aws-ec2-instance-connect-config";
rev = "1.1.17";
hash = "sha256-XXrVcmgsYFOj/1cD45ulFry5gY7XOkyhmDV7yXvgNhI=";
ec2-instance-connect-script = stdenvNoCC.mkDerivation {
name = "ec2-instance-connect-script";
src = pkgs.fetchFromGitHub {
owner = "aws";
repo = "aws-ec2-instance-connect-config";
rev = "1.1.17";
hash = "sha256-XXrVcmgsYFOj/1cD45ulFry5gY7XOkyhmDV7yXvgNhI=";
};

dontBuild = true;
dontPatchShebangs = true;
dontPatch = true;

installPhase = ''
mkdir -p $out/bin
cp $src/src/bin/eic_parse_authorized_keys $out/bin
cp $src/src/bin/eic_run_authorized_keys $out/bin
# TODO: move to fixup phase!
sed "s%^ca_path=/etc/ssl/certs$%ca_path=/etc/ssl/certs/ca-bundle.crt%" "src/bin/eic_curl_authorized_keys" > "$out/bin/eic_curl_authorized_keys"
chmod a+x "$out/bin/eic_curl_authorized_keys"
'';
};
in
buildFHSEnv {
name = "eic_run_authorized_keys";
runScript = "${src}/src/bin/eic_run_authorized_keys";
targetPkgs = (p: with p; [
coreutils
curl
openssh
cacert
gnugrep
util-linux
openssl
gawk
gnused
]);
}
buildFHSEnv {
name = "eic_run_authorized_keys";
runScript = "${ec2-instance-connect-script}/bin/eic_run_authorized_keys";
targetPkgs = p:
with p; [
coreutils;
curl
openssh
cacert
gnugrep
util-linux
openssl
gawk
gnused
];
}