Skip to content

Instantly share code, notes, and snippets.

@welefen
Created January 4, 2015 07:24
Show Gist options
  • Save welefen/bcc9dc1b513699819a3b to your computer and use it in GitHub Desktop.
Save welefen/bcc9dc1b513699819a3b to your computer and use it in GitHub Desktop.
Fskey
#!/bin/sh
#Here's a little one liner that'll do the trick (for passwordless auth) after you've done the ssh-keygen -d:
#how to use: /skey forum@zjm-forum-test10.zjm
if [ $# -lt 1 ]; then
echo "usage: $0 <username@host>"
echo " i.e.: $0 welefen@www.welefen.com"
echo
exit 1
fi
if [ -f "$HOME/.ssh/id_rsa.pub" ]; then
echo ''
else
ssh-keygen -t rsa
fi
target="$1"
ssh "$target" 'test -d .ssh || mkdir -m 0700 .ssh ; cat >>.ssh/authorized_keys && chmod 0600 .ssh/*' < ~/.ssh/id_rsa.pub
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment