Skip to content

Instantly share code, notes, and snippets.

@wilcollins
Last active June 30, 2018 21:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save wilcollins/bc420581da87962b8b47 to your computer and use it in GitHub Desktop.
Save wilcollins/bc420581da87962b8b47 to your computer and use it in GitHub Desktop.
SSH KeyGen+Copy Bash Script (quick ssh key setup)
#!/bin/bash
#
# Creates an SSH key on a client machine, applies the appropriate file permissions,
# copies to the local ~/.ssh directory, & copies to specified server
#
# parameters:
# ..1 newKeyFileName
# ..2 user@server
#
# usage :
# ./sshKeyGen.sh newKey user@server.com
#
ssh-keygen -t rsa -f $1
chmod 600 $1
chmod 600 $1.pub
mv $1 ~/.ssh/$1.pem
cp $1.pub ~/.ssh/$1
mv $1.pub ~/.ssh/$1.pub
ssh-copy-id -i ~/.ssh/$1.pub $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment