Skip to content

Instantly share code, notes, and snippets.

@kamilziajka
Created May 30, 2017 21:04
Show Gist options
  • Save kamilziajka/34c24ebbd5c2aa351c915537a3a02e4c to your computer and use it in GitHub Desktop.
Save kamilziajka/34c24ebbd5c2aa351c915537a3a02e4c to your computer and use it in GitHub Desktop.
ssh-keygen
#!/usr/bin/env bash
# ./ssh-keygen.sh ~/test
# will create ~/test-public-key and ~/test-private-key
function keygen {
local key_path="${1}"
local key_public_path="${key_path}-public-key"
local key_private_path="${key_path}-private-key"
rm -f "${key_public_path}" "${key_private_path}"
ssh-keygen -f "${key_path}" -C '' -N '' -t rsa
mv "${key_path}" "${key_private_path}"
mv "${key_path}.pub" "${key_public_path}"
chmod 600 "${key_public_path}" "${key_private_path}"
}
path=${1:-"ssh"}
keygen "${path}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment