install.fairie/home/private_dot_ssh/run_onchanges_after_generate-public-keys.tmpl

21 lines
627 B
Cheetah
Raw Normal View History

#!/usr/bin/env bash
{{ $sshFiles := (output "find" (joinPath .chezmoi.homeDir ".ssh") "-type" "f") -}}
{{- range $sshFile := splitList "\n" $sshFiles -}}
{{- if ne $sshFile "" -}}
# {{ $sshFile }} hash: {{ $sshFile | sha256sum }}
{{ end -}}
{{- end }}
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
logg info '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 info 'Generating missing public key for `'"$FILE"'`'
ssh-keygen -f "$FILE" -y > "${FILE}.pub"
fi
done