Skip to content

Commit

Permalink
imp: ensure bootstrap key removal service works when .ssh dir is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
johnalotoski committed Mar 28, 2024
1 parent bb30d48 commit a250504
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flake/nixosModules/profile-common.nix
Expand Up @@ -71,6 +71,7 @@
name = "remove-ssh-bootstrap-key";
runtimeInputs = [fd gnugrep gnused];
text = ''
mkdir -p /root/.ssh && chmod 0600 /root/.ssh
if ! [ -f /root/.ssh/.bootstrap-key-removed ]; then
# Verify auth keys is properly hooked into sshd
if ! grep -q 'AuthorizedKeysCommand /etc/ssh/auth-keys-hub --user %u' /etc/ssh/sshd_config; then
Expand All @@ -97,7 +98,9 @@
# Remove the bootstrap key and set a marker
echo "Removing the bootstrap key from /root/.ssh/authorized_keys"
sed -i '/bootstrap/d' /root/.ssh/authorized_keys
if [ -s /root/.ssh/authorized_keys ]; then
sed -i '/bootstrap/d' /root/.ssh/authorized_keys
fi
touch /root/.ssh/.bootstrap-key-removed
fi
'';
Expand Down

0 comments on commit a250504

Please sign in to comment.