Skip to content
Snippets Groups Projects
Commit 820966c8 authored by Alan Nelson's avatar Alan Nelson
Browse files

Add generate_svc_account_key.sh

parents
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#
# This script generates an ed25519 SSH key for a service account,
# adds the public part to the service account's authorized_keys file,
# and prints the private part of the key to the console.
#
read -p 'Service Account: ' account
sudo -u "$account" -H -- bash -c "cd ~; mkfifo key key.pub && cat key && cat key.pub >> /etc/ssh/authorized_keys/$account & echo \"y\" | ssh-keygen -oq -t ed25519 -N \"\" -f key &>/dev/null; rm key key.pub"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment