Skip to content

Commit

Permalink
feat: add multiple ssh key config for github
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzc committed Sep 10, 2024
1 parent c0ed5e4 commit 5045441
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
36 changes: 36 additions & 0 deletions dot_config/private_1Password/private_ssh/private_agent.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is the 1Password SSH agent config file, which allows you to customize the
# behavior of the SSH agent running on this machine.
#
# You can use it to:
# * Enable keys from other vaults than the Private vault
# * Control the order in which keys are offered to SSH servers
#
# EXAMPLE
#
# By default, all keys in your Private vault(s) are enabled:
#
# [[ssh-keys]]
# vault = "Private"
#
# You can enable more keys by adding more `[[ssh-keys]]` entries.
# For example, to first enable item "My SSH Key" from "My Custom Vault":
#
# [[ssh-keys]]
# item = "My SSH Key"
# vault = "My Custom Vault"
#
# [[ssh-keys]]
# vault = "Private"
#
# You can test the result by running:
#
# SSH_AUTH_SOCK=~/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock ssh-add -l
#
# More examples can be found here:
# https://developer.1password.com/docs/ssh/agent/config

[[ssh-keys]]
vault = "Personal"

[[ssh-keys]]
vault = "Work"
12 changes: 6 additions & 6 deletions dot_gitconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# vim:ft=gitconfig ts=2 sw=2

[user]
email = [email protected]
name = xvzc
signingkey = "~/.ssh/xvzc.pub"
email = [email protected]
name = xvzc
signingkey = "~/.ssh/xvzc.pub"

[includeIf "gitdir:~/work/"]
path = ~/.gitconfig
[includeIf "gitdir:~/_work/"]
path = ~/_work/.gitconfig

[init]
defaultBranch = main
defaultBranch = main

15 changes: 5 additions & 10 deletions init_private_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@ op read --force \
| tr -d "\015" > ~/.ssh/xvzc.pub && \
chmod 600 ~/.ssh/xvzc.pub

# op read --force \
# "op://mbqg52gjbireiglzwrrck5nbcm/br6vmskxg3yyesbwjfv2zev46y/private key?ssh-format=openssh" \
# | tr -d '\015' > ~/.ssh/xvzc && \
# chmod 600 ~/.ssh/xvzc
#
op read --force \
"op://qjudjahzxxfny6mrwuvrlfbmpm/njvsdrtofuehwaftqoemmqe4cm/public key" \
| tr -d "\015" > ~/.ssh/kwanghoo93.pub && \
chmod 600 ~/.ssh/kwanghoo93.pub

op read --force \
"op://mbqg52gjbireiglzwrrck5nbcm/6dnb4xqgeh2voofslw3dr35dw4/public key" \
| tr -d '\015' > ~/.ssh/arch.pub && \
chmod 600 ~/.ssh/arch.pub

# op read --force \
# "op://mbqg52gjbireiglzwrrck5nbcm/6dnb4xqgeh2voofslw3dr35dw4/private key?ssh-format=openssh" \
# | tr -d '\015' > ~/.ssh/arch && \
# chmod 600 ~/.ssh/arch
13 changes: 13 additions & 0 deletions private_dot_ssh/private_config.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Host home
IdentityFile ~/.ssh/arch.pub
IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"

Host kwanghoo93.github.com
HostName github.com
ForwardAgent yes
IdentitiesOnly yes
IdentityFile ~/.ssh/kwanghoo93.pub
IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"

Host xvzc.github.com
HostName github.com
ForwardAgent yes
Expand All @@ -26,6 +33,12 @@ Host xvzc.github.com
IdentitiesOnly yes
IdentityFile ~/.ssh/xvzc.pub

Host kwanghoo93.github.com
HostName github.com
ForwardAgent yes
IdentitiesOnly yes
IdentityFile ~/.ssh/kwanghoo93.pub

Match Host * exec "test -z $SSH_CONNECTION"
IdentityAgent "~/.1password/agent.sock"
# {{ end }}
Expand Down

0 comments on commit 5045441

Please sign in to comment.