2021-05-09 23:22:48 +02:00
|
|
|
# Do not copy this! It is insecure. This is only okay because we are testing.
|
2023-02-18 20:45:57 +01:00
|
|
|
{config, ...}: {
|
2023-01-29 17:36:01 +01:00
|
|
|
system.activationScripts.agenixInstall.deps = ["installSSHHostKeys"];
|
2021-05-09 23:22:48 +02:00
|
|
|
|
|
|
|
system.activationScripts.installSSHHostKeys.text = ''
|
2023-02-18 20:45:57 +01:00
|
|
|
USER1_UID="${toString config.users.users.user1.uid}"
|
|
|
|
USERS_GID="${toString config.users.groups.users.gid}"
|
|
|
|
|
2023-02-16 22:18:54 +01:00
|
|
|
mkdir -p /etc/ssh /home/user1/.ssh
|
2023-02-18 20:45:57 +01:00
|
|
|
chown $USER1_UID:$USERS_GID /home/user1/.ssh
|
2023-02-16 22:18:54 +01:00
|
|
|
(
|
|
|
|
umask u=rw,g=r,o=r
|
|
|
|
cp ${../example_keys/system1.pub} /etc/ssh/ssh_host_ed25519_key.pub
|
|
|
|
cp ${../example_keys/user1.pub} /home/user1/.ssh/id_ed25519.pub
|
2023-02-18 20:45:57 +01:00
|
|
|
chown $USER1_UID:$USERS_GID /home/user1/.ssh/id_ed25519.pub
|
2023-02-16 22:18:54 +01:00
|
|
|
)
|
2021-05-09 23:22:48 +02:00
|
|
|
(
|
|
|
|
umask u=rw,g=,o=
|
|
|
|
cp ${../example_keys/system1} /etc/ssh/ssh_host_ed25519_key
|
2023-02-16 22:18:54 +01:00
|
|
|
cp ${../example_keys/user1} /home/user1/.ssh/id_ed25519
|
2023-02-18 20:45:57 +01:00
|
|
|
chown $USER1_UID:$USERS_GID /home/user1/.ssh/id_ed25519
|
2021-05-09 23:22:48 +02:00
|
|
|
touch /etc/ssh/ssh_host_rsa_key
|
|
|
|
)
|
2023-02-19 19:20:07 +01:00
|
|
|
cp -r "${../example}" /tmp/secrets
|
|
|
|
chmod -R u+rw /tmp/secrets
|
|
|
|
chown -R $USER1_UID:$USERS_GID /tmp/secrets
|
2021-05-09 23:22:48 +02:00
|
|
|
'';
|
|
|
|
}
|