Skip to content

Instantly share code, notes, and snippets.

@jacksonporter
Last active March 20, 2020 23:38
Show Gist options
  • Save jacksonporter/0a394e039eb0f7c63890a3a217f9c9e6 to your computer and use it in GitHub Desktop.
Save jacksonporter/0a394e039eb0f7c63890a3a217f9c9e6 to your computer and use it in GitHub Desktop.
Sets up basic entry for the current user via SSH
#!/usr/bin/env bash
# Re-written by Jackson Porter, part of fork: https://gist.github.com/jacksonporter/34e59e05c1df7b7bfc7e29ae9fef8436
# SSH Key generation/new user reference: https://www.digitalocean.com/community/questions/ubuntu-16-04-creating-new-user-and-adding-ssh-keys
set -e
eval "$(curl -fsSL https://gist.github.com/jacksonporter/791145218e977ef9165abd9fdf8fbfd4/raw)" # obtains my common bash utilies script and "sources" it
print_warning "generating .ssh dir in $(pwd) as user ${GREEN_COLOR}$(whoami)${YELLOW_COLOR}."
mkdir .ssh
chmod 0700 .ssh
pushd .ssh
print_success "Created .ssh directory"
print_warning "\nCreating SSH keys, placing the generated public key in authorized_keys\n"
ssh-keygen -q -a 1000 -b 4096 -C "" -E sha256 -o -t rsa -N "" -f "./id_rsa"
cat ./id_rsa.pub >> authorized_keys
rm ./id_rsa.pub
popd > /dev/null
print_success "Created SSH keys, placed public key in authorized keys and deleted the public key. Make sure to copy the private key \"id_rsa\" under ${HOME}/.ssh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment