Update dotfiles/.local/share/chezmoi/home/dot_ssh/create_encrypted_private_readonly_private_id_rsa.tmpl, dotfiles/.local/share/chezmoi/home/dot_ssh/run_onchanges_after_generate-public-keys.tmpl

This commit is contained in:
Brian Zalewski 2022-11-25 05:05:02 +00:00
parent f536b87dcd
commit e8c18c9904
2 changed files with 12 additions and 7 deletions

View file

@ -1,5 +1,7 @@
{{- if ( bitwarden "item" "dev.betelgeuse.ssh.personal.id_rsa.private" ).notes -}}
{{- ( bitwarden "item" "dev.betelgeuse.ssh.personal.id_rsa.private" ).notes -}}
{{- $bwAuthenticated = eq (fromJson (output "bw" "status")).status "authenticated" }}
{{- if $bwAuthenticated -}}
{{- writeToStdout "BitWarden is authenticated!" -}}
{{- (bitwarden "item" "dev.betelgeuse.ssh.personal.id_rsa.private").notes -}}
{{- else -}}
{{- $sshLocation = (joinPath .chezmoi.homeDir ".ssh" "id_rsa") -}}
{{- if not (stat $sshLocation) -}}

View file

@ -1,12 +1,15 @@
#!/usr/bin/env bash
{{ $sshFiles = (output "find" "$HOME/.ssh" "-type" "f") }}
{{ range $sshFile := $sshFiles }}
# .ssh hash: {{ include ".ssh" | sha256sum }}
# {{ $sshFile }} hash: {{ include $sshFile | sha256sum }}
{{ end }}
{{ $sshFiles := (output "find" (joinPath .chezmoi.homeDir ".ssh") "-type" "f") -}}
{{- range $sshFile := splitList "\n" $sshFiles -}}
{{- if ne $sshFile "" -}}
# {{ $sshFile }} hash: {{ $sshFile | sha256sum }}
{{ end -}}
{{- end }}
source "$HOME/.config/shell/exports"
logg 'Ensuring RSA public keys are present'
find "$HOME/.ssh" -type f | while read FILE; do
if [ ! -f "${FILE}" ] && cat "$FILE" | grep 'BEGIN RSA PRIVATE KEY'; then
logg 'Generating missing public key for `'"$FILE"'`'