Skip to content
vovanphuPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

214 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dotfiles

My personal dotfiles managed by chezmoi. Motto: "One Config to Rule Them All."

πŸš€ Installation

1. Prerequisites

  • Bitwarden Account: You need a Bitwarden account with the following items:
    • Secure Notes: ssh-key-master-ed25519 and ssh-key-server-ed25519 (Private Keys).
      • Each item must have a custom field named exactly public_key containing the full SSH public key string (e.g., ssh-ed25519 AAAA... user@host). This field is read by authorized_keys.tmpl to populate ~/.ssh/authorized_keys on machines that accept SSH connections. Without it, authorized_keys will be empty.
    • Password: tailscale-auth-key (One-off key). Generate a new key for each new machine setup. Enable "Pre-approved" so devices auto-authorize.
  • Internet: Required for package downloads.

2. Quick Start

πŸͺŸ Windows (PowerShell Administrator)

The script automatically installs chezmoi, bitwarden-cli, git, tailscale, and provisions keys.

  • Option A: Interactive (Prompts for secrets):
    irm https://raw.githubusercontent.com/vovanphu/arx/master/install.ps1 | iex
  • Option B: Automated (Zero-touch, will auto-delete .env):
    @("BW_EMAIL=user@mail.com", "BW_PASSWORD=pass", "ROLE=centaur", "HOSTNAME=chiron", "USER_NAME='vovanphu'", "EMAIL_ADDRESS='vovanphu1012@gmail.com'") | Set-Content .env; irm https://raw.githubusercontent.com/vovanphu/arx/master/install.ps1 | iex
  • Option C: Direct Environment Injection (No temporary files):
    $env:BW_EMAIL="user@mail.com"; $env:BW_PASSWORD="pass"; $env:ROLE="centaur"; $env:HOSTNAME="chiron"; $env:USER_NAME="vovanphu"; $env:EMAIL_ADDRESS="vovanphu1012@gmail.com"; irm https://raw.githubusercontent.com/vovanphu/arx/master/install.ps1 | iex

🐧 Linux / WSL

Handles dependency checks, Bitwarden authentication, and SSH agent reuse.

  • Option A: Interactive:
    bash -c "$(curl -fsSL https://raw.githubusercontent.com/vovanphu/arx/master/install.sh)"
  • Option B: Automated (Zero-touch, will auto-delete .env):
    echo "BW_EMAIL=user@mail.com" > .env; echo "BW_PASSWORD=pass" >> .env; echo "ROLE=centaur" >> .env; echo "USER_NAME='vovanphu'" >> .env; bash -c "$(curl -fsSL https://raw.githubusercontent.com/vovanphu/arx/master/install.sh)"
  • Option C: Direct Environment Injection (No temporary files):
    export BW_EMAIL="user@mail.com" BW_PASSWORD="pass" ROLE="centaur" USER_NAME="vovanphu" EMAIL_ADDRESS="vovanphu1012@gmail.com" && bash -c "$(curl -fsSL https://raw.githubusercontent.com/vovanphu/arx/master/install.sh)"

πŸ€– Role Selection: "The Mythos"

We use a Mythological Role System to categorize machines. The system uses capability-based configuration instead of hardcoded role checks.

Role Taxonomy

All 10 roles are centrally defined with capabilities in .chezmoi.yaml.tmpl. Each role has 5 capabilities:

  • has_master_key - Gets master SSH key
  • has_server_key - Gets server SSH key
  • receives_ssh - Has authorized_keys configured
  • is_server - Server-specific configuration (headless, limited shell history)
  • install_desktop_tools - Installs GUI applications
Role Core Concept Typical Use Case Capabilities
centaur The Wise Commander Laptop/Mac. Admin, Management. πŸ”‘ Master Key, πŸ–₯️ Desktop
chimera The Hybrid Beast Windows Workstation + WSL. πŸ”‘ Master + Server Keys, πŸ” SSH, πŸ–₯️ Desktop
griffin The Guardian Portable Debit/KVM Lab. πŸ”‘ Server Key, πŸ” SSH, πŸ–₯️ Desktop
hydra The Undying Cluster Proxmox Host. πŸ”‘ Server Key, πŸ” SSH, πŸ–§ Server
cyclops The Strong General Purpose Server. πŸ”‘ Server Key, πŸ” SSH, πŸ–§ Server
kraken The Deep Storage Database Server. πŸ”‘ Server Key, πŸ” SSH, πŸ–§ Server
cerberus The Guardian Gate Security/Firewall Server. πŸ”‘ Server Key, πŸ” SSH, πŸ–§ Server
golem The Builder CI/CD Server. πŸ”‘ Server Key, πŸ” SSH, πŸ–§ Server
minion The Worker Compute Node. πŸ”‘ Server Key, πŸ” SSH, πŸ–§ Server
siren The Watchful Monitoring Server. πŸ”‘ Server Key, πŸ” SSH, πŸ–§ Server

πŸ“– Full Documentation: See ROLES.md for detailed role definitions, how to add new roles, and template usage examples.

✨ Features

πŸ—οΈ Architecture

  • 🎯 Centralized Role Taxonomy: Single source of truth for all role definitions in .chezmoi.yaml.tmpl
  • πŸ”§ Capability-Based Templates: Templates use capabilities (e.g., .has_master_key) instead of hardcoded roles
  • πŸ“¦ Centralized Packages: All software definitions live in packages.yaml, separating data from installation scripts
  • πŸ”„ File-Based Merge Logic: SSH merge scripts detect files, not roles (works for any role without code changes)

πŸ” Security & SSH Management

  • πŸ”‘ Automated Secrets: Pulls SSH Keys directly from Bitwarden (ssh-key-master-ed25519 -> ~/.ssh/id_ed25519_dotfiles_master)
  • πŸ›‘οΈ Namespaced Keys: Uses explicit filenames to avoid conflicts with system defaults
  • πŸ’Ύ Smart Backup: Automatically backs up ~/.ssh before deployment (timestamped: ~/.ssh.backup.YYYYMMDD_HHMMSS)
  • πŸ”„ Intelligent Merge: Preserves old SSH keys and custom config entries when re-installing
  • 🧹 Backup Retention: Automatically keeps only 3 most recent backups (prevents disk bloat)
  • πŸ”’ Session Cleanup: Clears BW_SESSION after installation (both success and error paths)
  • πŸͺŸ Windows Admin Fix: Auto-configures C:\ProgramData\ssh\administrators_authorized_keys for admin accounts
  • πŸ”§ Local Overrides: Supports ~/.ssh/config.local for custom SSH hosts not managed by dotfiles

🌐 Connectivity & Integration

  • 🏷️ Mythological Name Pools: Curated lists of names (e.g., chiron, polyphemus) for each role
  • 🌐 Zero-Touch Tailscale: Automatically authenticates via Bitwarden and configures MagicDNS
  • πŸ”— Hostname Sync: Detects mismatch between config and OS hostname, prompting for safe rename

🧠 Intelligent Scripts

  • βœ… Safety First: Soft-fails if Bitwarden is unreachable, validates session before template rendering
  • πŸͺŸ Windows: Auto-starts ssh-agent, handles bw login/unlock/sync
  • 🐧 WSL: Implements Socket Reuse so all terminal tabs share one ssh-agent session
  • πŸ”„ Self-Healing: Automatically derives SSH public keys (.pub) whenever private keys change
  • 🎨 GUI Ready: Automatically installs FiraCode Nerd Font on Windows and Linux (workstation roles)
  • 🐚 Unified Shell: Starship prompt & aliases consistent across PowerShell and Bash
  • πŸ’Ύ Persistent tmux: tmux-resurrect + tmux-continuum on every machine with tmux (cloned without TPM). Auto-saves session snapshots every 15 min; auto-restore is off β€” restore on demand, then list & attach

πŸ“Š Quality & Consistency

  • βœ… 100% Platform Parity: Identical behavior on Linux and Windows (verified via SSH_FLOW_REVIEW.md)
  • 🎯 Zero Hardcoded Roles: All templates use capability checks (maintainable, no copy-paste errors)
  • πŸ” Comprehensive Testing: Full SSH flow review with security audit trail

πŸ–₯️ Tools

tmux

Prefix: C-a (Ctrl+a, thαΊ£ ra, rα»“i bαΊ₯m phΓ­m tiαΊΏp theo).

Session

Command Action
tmux New session (auto name)
tmux new -s <name> New session with name
tmux ls List sessions
tmux a Attach to last session
tmux a -t <name> Attach to named session
prefix + d Detach (session stays alive)

Window (tab)

Key Action
prefix + c New window
prefix + , Rename window
prefix + n / p Next / previous window
prefix + 0..9 Jump to window by number
prefix + w List windows (j/k to navigate)
prefix + & Close window

Pane (split)

Key Action
prefix + | Vertical split
prefix + - Horizontal split
Alt + h/j/k/l Move between panes (no prefix)
prefix + H/J/K/L Resize pane
prefix + z Zoom pane (toggle fullscreen)
prefix + x Close pane

Copy mode β€” enter with prefix + [, exit with q

Key Action
h/j/k/l Navigate
C-u / C-d Page up / down
/ Search
v Begin selection
y Copy and exit
prefix + ] Paste

Other

Key Action
prefix + r Reload ~/.tmux.conf
prefix + $ Rename session
prefix + ? List all keybindings
prefix + . Change window index number
prefix + :move-window -t <n> Move window to position n (999 = end)

Persistence (resurrect + continuum)

Sessions, windows, panes (and pane contents) survive a reboot. Snapshots are saved automatically every 15 min, but nothing is restored automatically β€” you bring sessions back only when you want them, then list and attach as usual.

Key Action
prefix + C-s Save snapshot now
prefix + C-r Restore last snapshot
# after a reboot / fresh login
tmux a 2>/dev/null || tmux        # start a tmux server
# prefix + C-r                    # restore the saved sessions
tmux ls                           # list what came back
tmux a -t <name>                  # attach to one

Plugins are cloned to ~/.tmux/plugins automatically by chezmoi apply (no TPM) on every machine that has tmux.

Typical SSH workflow

ssh cyclops
tmux a || tmux new -s work   # attach or create
# work across multiple windows/panes
# disconnect or lose connection
ssh cyclops
tmux a                        # everything still there

❓ Troubleshooting

Factory Reset (Re-select Role/Hostname)

The system remembers your choices in ~/.config/chezmoi/chezmoi.toml. To force a fresh start:

  • Linux: rm ~/.config/chezmoi/chezmoi.toml
  • Windows: Remove-Item $env:USERPROFILE\.config\chezmoi\chezmoi.toml

SSH Guest/VM Setup

If you need to configure SSH for a Windows VM or a new target machine, refer to the following guide:

Then run the install script again.

πŸ“š Documentation

🎯 Recent Improvements (2026-02-23)

Security Enhancements βœ…

  • βœ… BW_SESSION Cleanup: Automatically cleared after installation (both success and error paths)
  • βœ… Session Validation: Pre-check Bitwarden session before template rendering (Linux + Windows)
  • βœ… Backup Retention: Keeps only 3 most recent SSH backups (prevents unlimited disk usage)

Architecture Improvements βœ…

  • βœ… Centralized Role Taxonomy: Single source of truth eliminates inconsistencies
  • βœ… Capability-Based Templates: No more hardcoded role checks (easier maintenance)
  • βœ… File-Based Merge: SSH merge scripts work for ANY role without code changes
  • βœ… Near-Complete Platform Parity: Verified functional equivalence on Linux and Windows
    • ⚠️ Note: Environment variable cleanup has minor timing differences between platforms due to process model differences (Bash trap vs PowerShell scope). Both methods are secure but behavior is not byte-identical.

Consistency Score: 92% β†’ 98% βœ… (platform limitations acknowledged) Security Issues: 3 β†’ 0 βœ… Platform Parity: 10/12 β†’ 13/13 βœ… (functional equivalence achieved)

πŸ“‹ Known Issues / TODO

πŸ”΄ High Priority

  • DRY Violation β€” Role Lists x3: Role capabilities are defined in roles: (L67-140), then manually duplicated in roles_with_* groups (L154-166), then duplicated again in has_* checks (L171-175). Adding a new role requires updating 3 places β†’ error-prone.
  • Hardcoded Role Checks in Scripts: run_once_install-packages.sh.tmpl hardcodes workstation roles (centaur || chimera || griffin) instead of using the .is_workstation capability. Same pattern at lines 38, 80, 140.

🟑 Medium Priority

  • SSH Key Add Logic Bug: dot_bashrc.tmpl L84-85 checks ssh-add -l exit code to decide whether to add key. Exit 0 = "has any identity" (not necessarily the right one). Should check by key fingerprint instead.
  • PowerShell SSH Agent: powershell_profile.ps1.tmpl L32 β€” Get-Service ssh-agent throws if service doesn't exist. Needs -ErrorAction SilentlyContinue.
  • Tailscale Fallback Download: run_once_install-packages.ps1.tmpl L79-89 downloads and executes .exe without checksum verification.
  • Error Handling: Package installation failures only warn, don't fail the script. Consider stricter error handling.

🟒 Low Priority / Nits

  • SSH Agent: Add wait/retry loop to ensure service is ready before adding keys.
  • Duplicate Comment: dot_bashrc.tmpl L63-64 has two SSH Agent Auto-Load comments.
  • Redundant Git Alias: dot_gitconfig.tmpl defines st = status which overlaps with shell alias st = "git status".
  • Trailing Blank Lines: run_once_install-packages.ps1.tmpl has 5 trailing blank lines (L118-122).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages