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

22 lines
703 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" }}
2023-03-19 23:38:30 -07:00
logg info 'Ensuring public keys are present'
2023-03-20 12:22:58 -07:00
find "$HOME/.ssh" -type f -maxdepth 1 ! -name "*.pub" ! -name "authorized_keys*" ! -name "known_host*" ! -name "config" | while read FILE; do
2023-03-19 23:38:30 -07:00
if [ ! -f "${FILE}.pub" ]; then
logg info 'Generating missing public key for `'"$FILE"'`'
ssh-keygen -f "$FILE" -y > "${FILE}.pub"
2023-03-20 02:32:51 -07:00
chmod 600 "${FILE}.pub"
fi
done