Skip to content

Instantly share code, notes, and snippets.

@vlrmprjct
Forked from wilcollins/sshKeyGen.sh
Last active November 8, 2017 08:11
Show Gist options
  • Save vlrmprjct/6e2853e3b5717fee521905d12a2b2790 to your computer and use it in GitHub Desktop.
Save vlrmprjct/6e2853e3b5717fee521905d12a2b2790 to your computer and use it in GitHub Desktop.
SSH KeyGen+Copy Bash Script (quick ssh key setup) #ssh #linux
#!/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