alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
tools.install-ssh-keys: init
author
lassulus
date
1 year ago
(Jul 5, 2025, 2:51 PM CEST)
commit
6cd1f69a
6cd1f69ac772714d803dcfeb017625635731a314
parent
589acf5c
589acf5c301f695992394880b15b05dbbba755d6
+38
1 changed file
Expand all
Collapse all
Unified
Split
tools
install-ssh-keys
flake-module.nix
+38
tools/install-ssh-keys/flake-module.nix
View file
Reviewed
···
1
1
+
{ self, ... }:
2
2
+
{
3
3
+
perSystem =
4
4
+
{ pkgs, lib, ... }:
5
5
+
let
6
6
+
authorizedKeysFile = pkgs.writeText "authorized_keys" ''
7
7
+
# SSH keys installed by install-ssh-keys tool
8
8
+
# Generated from self.keys.ssh
9
9
+
10
10
+
${lib.concatMapStringsSep "\n" (key: key.public) (lib.attrValues self.keys.ssh)}
11
11
+
'';
12
12
+
in
13
13
+
{
14
14
+
packages.install-ssh-keys = pkgs.writeShellApplication {
15
15
+
name = "install-ssh-keys";
16
16
+
runtimeInputs = [ ];
17
17
+
text = ''
18
18
+
set -euo pipefail
19
19
+
20
20
+
# Check if we're running as root
21
21
+
if [[ $EUID -ne 0 ]]; then
22
22
+
echo "Not running as root. Using sudo to install keys to /root/.ssh/authorized_keys"
23
23
+
exec sudo "$0" "$@"
24
24
+
fi
25
25
+
26
26
+
# Create /root/.ssh directory if it doesn't exist
27
27
+
mkdir -p /root/.ssh
28
28
+
chmod 700 /root/.ssh
29
29
+
30
30
+
# Append the authorized_keys
31
31
+
cat ${authorizedKeysFile} >> /root/.ssh/authorized_keys
32
32
+
chmod 600 /root/.ssh/authorized_keys
33
33
+
34
34
+
echo "Appended SSH keys to /root/.ssh/authorized_keys: ${lib.concatStringsSep ", " (lib.attrNames self.keys.ssh)}"
35
35
+
'';
36
36
+
};
37
37
+
};
38
38
+
}