Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions home-manager/programs/ssh/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
extraOptions = {
IgnoreUnknown = "UseKeychain";
UseKeyChain = "yes";
# Enable post-quantum key exchange algorithms
# sntrup761x25519 is a hybrid post-quantum algorithm combining
# Streamlined NTRU Prime (sntrup761) with X25519
KexAlgorithms = "sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256";
# Prefer modern host key algorithms
HostKeyAlgorithms = "ssh-ed25519-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-256";
# Prefer modern public key algorithms
PubkeyAcceptedAlgorithms = "ssh-ed25519-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-256";
Comment on lines +23 to +30

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cd home-manager/programs/ssh && wc -l default.nix && head -40 default.nix

Repository: shunkakinoki/dotfiles

Length of output: 1635


🏁 Script executed:

rg "KexAlgorithms|HostKeyAlgorithms|PubkeyAcceptedAlgorithms" home-manager/programs/ssh/default.nix -A 2 -B 2

Repository: shunkakinoki/dotfiles

Length of output: 809


🏁 Script executed:

# Check formatting: line length in the file
awk 'NR>=23 && NR<=30 {print NR": "length($0)" chars: "$0}' home-manager/programs/ssh/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 960


🌐 Web query:

OpenSSH 8.5 sntrup761x25519-sha512 post-quantum key exchange algorithm introduction date

💡 Result:

The sntrup761x25519-sha512 hybrid post‑quantum KEX was added in OpenSSH 8.5, which was released on March 3, 2021. [1][2]

Sources:
[1] OpenSSH release notes — OpenSSH 8.5/8.5p1 (2021-03-03). [2] Announcement / changelog noting sntrup761x25519-sha512 in OpenSSH 8.5.


Line length violations in SSH configuration.

The security improvements with sntrup761x25519-sha512@openssh.com and modern algorithms are sound, however lines 26, 28, and 30 exceed the 100-character limit (147, 171, and 178 characters respectively), violating the Nix formatting guideline. These algorithm lists should be split across multiple lines or refactored to meet the formatting requirement.

🤖 Prompt for AI Agents
In home-manager/programs/ssh/default.nix around lines 23 to 30, the long
KexAlgorithms, HostKeyAlgorithms and PubkeyAcceptedAlgorithms string values
exceed the 100-character line limit; split each long comma-separated algorithm
list across multiple source lines so no line exceeds 100 characters — for
example break the algorithm lists into multiple string literals concatenated
across lines or represent them as a list and join with commas (using
builtins.concatStringsSep) so formatting stays within the limit while preserving
the exact comma-separated values.

};
};
"localhost" = {
Expand All @@ -30,6 +38,7 @@
};
"github.com" = {
serverAliveInterval = 0;
identityFile = "~/.ssh/id_ed25519_github";

Copilot AI Dec 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GitHub SSH configuration now specifies an identity file (/.ssh/id_ed25519_github) that overrides the global default (/.ssh/id_ed25519). However, there's no fallback mechanism if the GitHub-specific key doesn't exist. Consider whether the global default should remain as a fallback option, especially during the transition period when this key might not be deployed yet on all systems.

Suggested change
identityFile = "~/.ssh/id_ed25519_github";
identityFile = [ "~/.ssh/id_ed25519_github" "~/.ssh/id_ed25519" ];

Copilot uses AI. Check for mistakes.
extraOptions = {
ControlMaster = "auto";
ControlPath = "~/.ssh/github.sock";
Expand Down
4 changes: 4 additions & 0 deletions home-manager/services/dotfiles-updater/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ in
lib.makeBinPath [
pkgs.git
pkgs.bash
pkgs.coreutils
pkgs.gnumake
pkgs.curl
pkgs.nix
Comment on lines +43 to +46

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, examine the complete default.nix file
cat -n home-manager/services/dotfiles-updater/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 1930


🏁 Script executed:

# List files in the dotfiles-updater directory
ls -la home-manager/services/dotfiles-updater/

# Check for update.sh and install.sh
find home-manager/services/dotfiles-updater -name "*.sh" -type f

Repository: shunkakinoki/dotfiles

Length of output: 344


🏁 Script executed:

# Read the update.sh script
cat -n home-manager/services/dotfiles-updater/update.sh

# Also search for install.sh in case it exists elsewhere
find . -name "install.sh" -type f 2>/dev/null | head -20

Repository: shunkakinoki/dotfiles

Length of output: 549


🏁 Script executed:

# Read the install.sh script
cat -n ./install.sh | head -100

Repository: shunkakinoki/dotfiles

Length of output: 4493


🏁 Script executed:

# Search for 'make' usage in install.sh
grep -n "make" ./install.sh

# Get the full length of install.sh to understand its scope
wc -l ./install.sh

Repository: shunkakinoki/dotfiles

Length of output: 649


🏁 Script executed:

# Let's also check if there are any other dependencies in install.sh
grep -nE "(command -v|which|apt-get|brew install)" ./install.sh | head -30

Repository: shunkakinoki/dotfiles

Length of output: 580


Darwin launchd service requires equivalent dependencies for consistency and reliability.

The update.sh script runs install.sh on both Darwin and Linux, and install.sh depends on curl (for Nix installation), gnumake, and nix. While the Darwin PATH includes fallback directories (/opt/homebrew/bin and /usr/local/bin), explicitly adding pkgs.gnumake, pkgs.curl, and pkgs.nix to the Darwin service PATH (lines 16-18) would ensure these tools are available without relying on prior installations or fallback paths, matching the Linux service configuration and preventing potential exit code 127 failures.

🤖 Prompt for AI Agents
In home-manager/services/dotfiles-updater/default.nix around lines 43-46 (and
update the Darwin service PATH block at lines 16-18), add pkgs.gnumake,
pkgs.curl, and pkgs.nix to the Darwin service PATH entries so the Darwin launchd
service explicitly includes those package binaries (matching the Linux service
configuration) rather than relying on fallback directories; update the PATH list
to include pkgs.gnumake, pkgs.curl, pkgs.nix alongside pkgs.coreutils.

Comment on lines +43 to +46

Copilot AI Dec 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title focuses on fixing the dotfiles-updater service, but the majority of changes are unrelated to that fix. The changes include:

  1. SSH key synchronization between galactica and kyber
  2. SSH configuration updates (post-quantum crypto, GitHub identity file)
  3. Agenix secrets management restructuring
  4. New rekey script and documentation

Consider splitting this into separate PRs:

  • One for the dotfiles-updater PATH fix (lines 43-46)
  • Another for the SSH key management infrastructure changes

This would make the changes easier to review and track in version control.

Copilot uses AI. Check for mistakes.
]
}";

Copilot AI Dec 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macOS launchd configuration includes additional PATH directories (:/opt/homebrew/bin:/usr/local/bin) that are not present in the Linux systemd configuration. While this may be intentional due to platform differences, consider whether Linux systems might need similar additional PATH directories for user-installed tools or if there's an equivalent location that should be included.

Suggested change
}";
}:/usr/local/bin:/usr/bin";

Copilot uses AI. Check for mistakes.
ExecStart = "${./update.sh}";
Expand Down
18 changes: 12 additions & 6 deletions named-hosts/galactica/secrets.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
let
# Galactica's SSH public key
galactica = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEKze2jlpV7SyTKA2ezqbumpCiDn+5Sj4z5SxrqfzesX shunkakinoki@gmail.com";
# Kyber's SSH public key
kyber = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO0IZtP3KSzY6GVSZ+R+VQYYfu3sEOVaQGDblQxAtwNM ubuntu@kyber";
# All machines that can decrypt shared secrets
allMachines = [ galactica kyber ];
in
Comment on lines +1 to +11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

You've done a great job refactoring this file to use a let block. To further improve maintainability and avoid duplicating public key definitions across multiple files (e.g., named-hosts/kyber/secrets.nix), consider centralizing the public key definitions. You could create a common file, for example named-hosts/public-keys.nix, and import it where needed. This would make adding new hosts or updating keys much easier.

Example named-hosts/public-keys.nix:

{
  galactica = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEKze2jlpV7SyTKA2ezqbumpCiDn+5Sj4z5SxrqfzesX shunkakinoki@gmail.com";
  kyber = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO0IZtP3KSzY6GVSZ+R+VQYYfu3sEOVaQGDblQxAtwNM ubuntu@kyber";
}

Then you could use it like this:

let
  publicKeys = import ../public-keys.nix;
  allMachines = with publicKeys; [ galactica kyber ];
in
{
  # ...
}

{
# Shared SSH key for GitHub authentication (accessible on all machines)
"keys/id_ed25519.age" = {
file = ./keys/id_ed25519.age;
publicKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEKze2jlpV7SyTKA2ezqbumpCiDn+5Sj4z5SxrqfzesX shunkakinoki@gmail.com"
];
publicKeys = allMachines;
};
# GPG key (galactica only)
"keys/gpg.age" = {
file = ./keys/gpg.age;
publicKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEKze2jlpV7SyTKA2ezqbumpCiDn+5Sj4z5SxrqfzesX shunkakinoki@gmail.com"
];
publicKeys = [ galactica ];
};
}
28 changes: 28 additions & 0 deletions named-hosts/kyber/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,31 @@ Once Tailscale is set up:
```bash
kyber # Fish abbreviation that runs: ssh ubuntu@kyber
```

## Syncing SSH Keys from Galactica

To sync the GitHub SSH key from galactica to kyber:

### On Galactica

```bash
cd ~/dotfiles
git pull
make rekey-galactica
git add named-hosts/galactica/keys/
git commit -m "chore(agenix): rekey secrets for kyber access"
git push
```

### On Kyber

```bash
cd ~/dotfiles
git pull
make switch

# Test GitHub access
ssh -T git@github.com
```

The SSH key will be automatically decrypted and deployed to `~/.ssh/id_ed25519_github`.
15 changes: 14 additions & 1 deletion named-hosts/kyber/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,20 @@ home-manager.lib.homeManagerConfiguration {

# Agenix configuration
age.identityPaths = [ "/home/${username}/.ssh/id_ed25519" ];
age.secrets = builtins.mapAttrs (name: value: { file = value.file; }) (import ./secrets.nix);
age.secrets = builtins.mapAttrs (
name: value: {
file = value.file;
# Deploy GitHub SSH key to ~/.ssh/ with correct permissions
} // (
if name == "keys/id_ed25519.age" then
{
path = "/home/${username}/.ssh/id_ed25519_github";
mode = "0600";
}
else
{ }
)
) (import ./secrets.nix);

programs.home-manager.enable = true;

Expand Down
38 changes: 38 additions & 0 deletions named-hosts/kyber/rekey-galactica.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Remotely rekey galactica secrets to include kyber's public key
# This script should be run from kyber to trigger the rekey on galactica

set -e

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better script safety and to be consistent with other scripts in this repository (like update.sh), it's recommended to use set -euo pipefail instead of just set -e.

  • u: Treats unset variables as an error.
  • o pipefail: Causes a pipeline to return the exit status of the last command in the pipe that failed, not the last command of the pipe.
Suggested change
set -e
set -euo pipefail


echo "🔑 Rekeying galactica secrets to include kyber..."
echo ""
echo "This will:"
echo "1. Connect to galactica via Tailscale SSH"
echo "2. Run the rekey command to re-encrypt secrets with both keys"
echo "3. Commit and push the changes"
echo ""

# Try Tailscale SSH first
if tailscale ssh shunkakinoki@galactica "cd ~/dotfiles && make rekey-galactica" 2>/dev/null; then
echo "✅ Rekey completed via Tailscale SSH"
else
echo "❌ Tailscale SSH failed. Please run this manually on galactica:"
echo ""
echo " cd ~/dotfiles"
echo " git pull"
echo " make rekey-galactica"
echo " git add named-hosts/galactica/keys/"
echo " git commit -m 'chore(agenix): rekey secrets for kyber access'"
echo " git push"
echo ""
exit 1
fi

# Pull the changes
echo ""
echo "📥 Pulling re-encrypted secrets..."

Copilot AI Dec 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script assumes it's run from a specific location but doesn't validate this. If the script fails at line 34 (cd ~/dotfiles), it will exit due to 'set -e', but the error message won't be clear about what went wrong. Consider adding a check to ensure the dotfiles directory exists before attempting to cd into it, or use a more specific error handling approach.

Suggested change
echo "📥 Pulling re-encrypted secrets..."
echo "📥 Pulling re-encrypted secrets..."
if [ ! -d ~/dotfiles ]; then
echo "❌ Error: ~/dotfiles directory does not exist. Please ensure it exists before running this script."
exit 1
fi

Copilot uses AI. Check for mistakes.
cd ~/dotfiles

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using ~ for the home directory in scripts can sometimes be brittle. It's more robust to use the $HOME environment variable explicitly. This ensures the path is correctly resolved even in less common execution contexts.

Suggested change
cd ~/dotfiles
cd "$HOME/dotfiles"

git pull

echo ""
echo "✅ Done! Now run: make switch"
31 changes: 17 additions & 14 deletions named-hosts/kyber/secrets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
# To add a new secret:
# 1. Add the secret definition here
# 2. Run: make encrypt-key-kyber KEY_FILE=/path/to/secret
let
# Galactica's SSH public key
galactica = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEKze2jlpV7SyTKA2ezqbumpCiDn+5Sj4z5SxrqfzesX shunkakinoki@gmail.com";
# Kyber's SSH public key
kyber = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO0IZtP3KSzY6GVSZ+R+VQYYfu3sEOVaQGDblQxAtwNM ubuntu@kyber";
# All machines that can decrypt shared secrets
allMachines = [ galactica kyber ];
in
{
# Tailscale auth key - generate from https://login.tailscale.com/admin/settings/keys
# "keys/tailscale-auth.age" = {
# file = ./keys/tailscale-auth.age;
# publicKeys = [
# # Kyber's SSH public key (run: ssh ubuntu@kyber "cat ~/.ssh/id_ed25519.pub")
# "ssh-ed25519 AAAA..."
# ];
# };
"keys/tailscale-auth.age" = {
file = ./keys/tailscale-auth.age;
publicKeys = [ kyber ];
};

# SSH key sync (your local key encrypted for kyber)
# "keys/id_ed25519.age" = {
# file = ./keys/id_ed25519.age;
# publicKeys = [
# "ssh-ed25519 AAAA..."
# ];
# };
# Shared SSH key for GitHub authentication (synced from galactica)
"keys/id_ed25519.age" = {
file = ../galactica/keys/id_ed25519.age;
Comment on lines +23 to +25

Copilot AI Dec 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The secret definition references a file from galactica's directory (../galactica/keys/id_ed25519.age). This creates a tight coupling between the two host configurations and means kyber cannot be deployed independently without galactica's secrets being present. While this may be intentional for shared secrets, consider documenting this dependency or using a shared secrets directory to make the relationship more explicit.

Suggested change
# Shared SSH key for GitHub authentication (synced from galactica)
"keys/id_ed25519.age" = {
file = ../galactica/keys/id_ed25519.age;
# Shared SSH key for GitHub authentication (shared between galactica and kyber; both hosts must have access to this file)
"keys/id_ed25519.age" = {
file = ../shared/keys/id_ed25519.age;

Copilot uses AI. Check for mistakes.
publicKeys = allMachines;
};
}
Loading