Generate SSH Keys Non-Interactively

Background

Sometimes you need a key without those pesky prompts.

Generate Key

#!/bin/bash

# Create SSH directory
mkdir -p ~/.ssh/

# Generate key
# -b 4096 (4096 bits, we're making this a bit stronger than the default)
# -t rsa (RSA key type)
# -f ~/.ssh/my_new_key (the output file)
# -q (silent, no console output)
# -N "" (no passphrase, but feel free to add one between the quotes)
ssh-keygen -b 4096 -t rsa -f ~/.ssh/my_new_key -q -N ""