install.fairie/dotfiles/.local/share/chezmoi/home/dot_ssh/create_encrypted_private_readonly_private_id_rsa.tmpl

13 lines
665 B
Cheetah
Raw Normal View History

{{- $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) -}}
{{- $sshKeygen = (output "ssh-keygen" "-b" "4096" "-t" "rsa" "-f" $sshLocation "-q" "-N" }}
{{- writeToStdout "Generated new SSH key since none were present and could not connect to BitWarden. It will be encrypted and included in your source." -}}
{{- end -}}
{{- include $sshLocation }}
{{ end }}