1
0

install.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. # Create a temporary directory
  3. temp=$(mktemp -d)
  4. # Function to cleanup temporary directory on exit
  5. cleanup() {
  6. rm -rf "$temp"
  7. }
  8. trap cleanup EXIT
  9. # Create the directory where sshd expects to find the host keys
  10. install -d -m755 "$temp/persist/etc/ssh"
  11. install -d -m755 "$temp/etc/ssh"
  12. # Decrypt your private key from the password store and copy it to the temporary directory
  13. cat ./ssh_host_ed25519_key.txt > "$temp/persist/etc/ssh/ssh_host_ed25519_key"
  14. cat ./ssh_host_rsa_key.txt > "$temp/persist/etc/ssh/ssh_host_rsa_key"
  15. cat ./ssh_host_ed25519_key.txt > "$temp/etc/ssh/ssh_host_ed25519_key"
  16. cat ./ssh_host_rsa_key.txt > "$temp/etc/ssh/ssh_host_rsa_key"
  17. # Set the correct permissions so sshd will accept the key
  18. chmod 600 "$temp/persist/etc/ssh/ssh_host_ed25519_key"
  19. chmod 600 "$temp/persist/etc/ssh/ssh_host_rsa_key"
  20. chmod 600 "$temp/etc/ssh/ssh_host_ed25519_key"
  21. chmod 600 "$temp/etc/ssh/ssh_host_rsa_key"
  22. # Install NixOS to the host system with our secrets
  23. nix run github:nix-community/nixos-anywhere -- \
  24. --disko-mode mount \
  25. --extra-files "$temp" \
  26. --flake .#odin \
  27. --target-host [email protected]