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 -}} {{- $bwAuthenticated = eq (fromJson (output "bw" "status")).status "authenticated" }}
{{- ( bitwarden "item" "dev.betelgeuse.ssh.personal.id_rsa.private" ).notes -}} {{- if $bwAuthenticated -}}
{{- writeToStdout "BitWarden is authenticated!" -}}
{{- (bitwarden "item" "dev.betelgeuse.ssh.personal.id_rsa.private").notes -}}
{{- else -}} {{- else -}}
{{- $sshLocation = (joinPath .chezmoi.homeDir ".ssh" "id_rsa") -}} {{- $sshLocation = (joinPath .chezmoi.homeDir ".ssh" "id_rsa") -}}
{{- if not (stat $sshLocation) -}} {{- if not (stat $sshLocation) -}}

View file

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