From 56394bf18d119c9d5a3b7babbadb9c015fadbe5d Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Tue, 17 Dec 2024 11:06:41 -0700 Subject: [PATCH] Update ssh signing config This breaks down the two configurations into personal and work/spatial. Based on config from https://markentier.tech/posts/2021/02/github-with-multiple-profiles-gpg-ssh-keys/ --- files/private_dot_config/git/config.tmpl | 12 +++++-- .../git/gitconfig.personal.tmpl | 3 ++ .../git/gitconfig.spatial.tmpl | 6 ++++ files/private_dot_ssh/config.tmpl | 32 +++++++++++++------ 4 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 files/private_dot_config/git/gitconfig.personal.tmpl create mode 100644 files/private_dot_config/git/gitconfig.spatial.tmpl diff --git a/files/private_dot_config/git/config.tmpl b/files/private_dot_config/git/config.tmpl index f3b0782..06a2f83 100644 --- a/files/private_dot_config/git/config.tmpl +++ b/files/private_dot_config/git/config.tmpl @@ -1,7 +1,15 @@ [user] name = {{ .name }} - email = {{ .email }} - signingkey = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC947DfJQryRkXvmotipCdU4S1vh3tqk9S+Mxei6imqL7Ebx7iA7kqdERset6ez3eOcLwu3UFftLSy1gg+ZeUJmRRyLPsPUhRBy/OCzMnhUv8K5slJmKEBSiJ1DR4VoEKitIQKJYrm5SZkfocQVhQovHgoXiN0Y8xGGzbSmCRNGW9z8t/R4GRToYAzFWOGvdz1GSfm9ZjjEb3yaA7Y3Kuk1xN1EabWKnvHz39VZfzHVcJ2eCuuoifmiHc++YgKdHYguUcicCEdhcgZHe1Wj/1CFrFj88frww9gej0n8GFm7Gi+GqnVbGlPdJ8ma50Hp7rYT/WUmtf8MAkGSu+0s5UJHO3e6O8/0z146+1dvau7e+Y07xtGloO2xwsmuj7O/5JAoqjfpxjysa3i2nWLr446/IlA2ikMJbnH2vqL8NRyAMB5yMgqIGSAoYcZAk0q0mkO/DxytkiEct/Tg2zJLgWGE8bGJJP2YVKXP9NPIN/2Q6yDQOLYTlkpkFH8GKBkxkP376aoN81vgmJIlKx23bDWwv8i8waDPUkyxwf32QiQNJNPrre6wqlWfqbF3ilvlH5QABieaVt+R6D7QajezLCC1ZrQOKYAyFO2YRMU2fgGeh125jVaX8QLFpRaorE4qXsMKbIbhqHIcMK3TK1dzcz6GqeeQ9crYPwT5u4zjmUzYpQ== + useConfigOnly = true + +[include] + path = ~/.gitconfig.personal + +[includeIf "gitdir:~/src/justin/"] + path = ~/.gitconfig.personal + +[includeIf "gitdir:~/src/spatiallabs/"] + path = ~/.gitconfig.contentful [github] user = {{ .username }} diff --git a/files/private_dot_config/git/gitconfig.personal.tmpl b/files/private_dot_config/git/gitconfig.personal.tmpl new file mode 100644 index 0000000..0ff87d1 --- /dev/null +++ b/files/private_dot_config/git/gitconfig.personal.tmpl @@ -0,0 +1,3 @@ +[user] + email = {{- onepasswordRead "op://Personal/Personal SSH Key/email" .onepasswordAccount -}} + signingKey = {{- onepasswordRead "op://Personal/Personal SSH Key/public key" .onepasswordAccount -}} diff --git a/files/private_dot_config/git/gitconfig.spatial.tmpl b/files/private_dot_config/git/gitconfig.spatial.tmpl new file mode 100644 index 0000000..ca5842d --- /dev/null +++ b/files/private_dot_config/git/gitconfig.spatial.tmpl @@ -0,0 +1,6 @@ +[user] + email = {{- onepasswordRead "op://Spatial/Spatial SSH Signing/email" .onepasswordAccount -}} + signingKey = {{- onepasswordRead "op://Spatial/Spatial SSH Signing/public key" .onepasswordAccount -}} + +[url "git@github.com-work"] + insteadOf = git@github.com diff --git a/files/private_dot_ssh/config.tmpl b/files/private_dot_ssh/config.tmpl index 96ffd43..5df00c8 100644 --- a/files/private_dot_ssh/config.tmpl +++ b/files/private_dot_ssh/config.tmpl @@ -1,13 +1,16 @@ -{{- if eq .chezmoi.os "darwin" }} -Include ~/.orbstack/ssh/config -{{ end }} +### -- PERSONAL/MAIN ACCOUNT -- -Host * - IdentityFile {{ .chezmoi.homeDir }}/.ssh/id_rsa - AddKeysToAgent yes - ServerAliveInterval 120 - ServerAliveCountMax 30 - ForwardAgent yes +Host github.com + Hostname github.com + User {{ .github_username }} + IdentityFile ~/.ssh/id_rsa + +### -- WORK PERSONA/ACCOUNT -- + +Host github.com-work + Hostname github.com + User {{ .github_username }} + IdentityFile ~/.ssh/spatial_signing Host homelab User justin @@ -28,3 +31,14 @@ Host studio Host udm User root HostName unifi + +Host * + AddKeysToAgent yes + ServerAliveInterval 120 + ServerAliveCountMax 30 + ForwardAgent yes + +{{- if eq .chezmoi.os "darwin" }} +Include ~/.orbstack/ssh/config +{{ end }} +