@@ -9,7 +9,7 @@ with lib;
99{
1010 config = {
1111
12− systemd.services."fetch-ec2-data" =
12+ systemd.services.fetch-ec2-data =
1313 { description = "Fetch EC2 Data";
1414
1515 wantedBy = [ "multi-user.target" "sshd.service" ];
@@ -48,13 +48,22 @@ with lib;
4848 # the supplied user data, if available. Otherwise sshd will
4949 # generate one normally.
5050 $wget http://169.254.169.254/2011-01-01/user-data > /root/user-data || true
51+
52+ mkdir -m 0755 -p /etc/ssh
53+
5154 key="$(sed 's/|/\n/g; s/SSH_HOST_DSA_KEY://; t; d' /root/user-data)"
5255 key_pub="$(sed 's/SSH_HOST_DSA_KEY_PUB://; t; d' /root/user-data)"
5356 if [ -n "$key" -a -n "$key_pub" -a ! -e /etc/ssh/ssh_host_dsa_key ]; then
54− mkdir -m 0755 -p /etc/ssh
5557 (umask 077; echo "$key" > /etc/ssh/ssh_host_dsa_key)
5658 echo "$key_pub" > /etc/ssh/ssh_host_dsa_key.pub
5759 fi
60+
61+ key="$(sed 's/|/\n/g; s/SSH_HOST_ED25519_KEY://; t; d' /root/user-data)"
62+ key_pub="$(sed 's/SSH_HOST_ED25519_KEY_PUB://; t; d' /root/user-data)"
63+ if [ -n "$key" -a -n "$key_pub" -a ! -e /etc/ssh/ssh_host_ed25519_key ]; then
64+ (umask 077; echo "$key" > /etc/ssh/ssh_host_ed25519_key)
65+ echo "$key_pub" > /etc/ssh/ssh_host_ed25519_key.pub
66+ fi
5867 '';
5968
6069 serviceConfig.Type = "oneshot";
@@ -72,6 +81,7 @@ with lib;
7281 # ec2-get-console-output.
7382 echo "-----BEGIN SSH HOST KEY FINGERPRINTS-----" > /dev/console
7483 ${config.programs.ssh.package}/bin/ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub > /dev/console
84+ ${config.programs.ssh.package}/bin/ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub > /dev/console
7585 echo "-----END SSH HOST KEY FINGERPRINTS-----" > /dev/console
7686 '';
7787 serviceConfig.Type = "oneshot";