Skip to content

Commit

Permalink
✨ bugfixes and better cp
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuDR committed Dec 4, 2024
1 parent bd8d04e commit 218d022
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,27 @@ hm *ARGS:
exit 1
fi
# Generate and copy keys with updated naming convention
# Generate and copy public keys with updated naming convention to `cp`
generate-keys cp="":
#!/usr/bin/env bash
set -euo pipefail
HOST=$(just _get_hosts | fzf --prompt="Select host: " --query="$HOSTNAME" --select-1) || HOST=$HOSTNAME
# Create directories
sudo mkdir -p "/etc/${HOST}"
mkdir -p ~/.config/agenix
# Generate system key with new naming convention
sudo ssh-keygen -t ed25519 -C "agenix-${HOST}" -f "/etc/${HOST}/agenix_${HOST}_system" -N ""
# Generate user key with new naming convention
ssh-keygen -t ed25519 -C "agenix-${USER}@${HOST}" -f ~/.config/agenix/agenix-key -N ""
# Handle copying with new naming convention
if [ "{{cp}}" = "cp" ]; then
# System key
sudo cp "/etc/${HOST}/agenix_${HOST}_system.pub" "/etc/${HOST}/agenix-${HOST}-system.pub"
if [ -n "{{cp}}" ]; then
mkdir -p "{{cp}}"
sudo cp "/etc/${HOST}/agenix_${HOST}_system.pub" "{{cp}}/agenix-${HOST}-system.pub"
cp ~/.config/agenix/agenix-key.pub "{{cp}}/agenix-${HOST}-${USER}.pub"
# User key
cp ~/.config/agenix/agenix-key.pub ~/.config/agenix/agenix-${HOST}-${USER}.pub
echo "Public keys copied to {{cp}}"
fi
echo "SSH keys generated and copied successfully for host: $HOST"
Expand Down

0 comments on commit 218d022

Please sign in to comment.