Skip to content
Snippets Groups Projects
Select Git revision
  • 820966c8231cc2e2bfbd0e1283c373411b919acd
  • master default protected
2 results

generate_svc_account_key.sh

Blame
  • generate_svc_account_key.sh 453 B
    #!/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"