Created
June 24, 2014 12:10
-
-
Save zerdliu/8c40fd64f3e91ad88f2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function usage { | |
cat <<EOF | |
USAGE: $0 | |
set/unset ssh auth | |
set : ln -s $0 set_ssh.sh | |
unset: ln -s $0 unset_ssh.sh | |
$0 user@server | |
$0 user@ip | |
$0 server | |
$0 ip | |
EOF | |
exit 1 | |
} | |
if [[ $# -eq 0 || $# -gt 1 ]] ; then | |
usage | |
fi | |
server=$1 | |
if [[ $0 == "set_ssh.sh" ]] ; then | |
cat ~/.ssh/id_rsa.pub ~/.ssh/id_dsa.pub | | |
ssh ${server} 'mkdir -p ~/.ssh ; cat - >> ~/.ssh/authorized_keys' | |
elif [[ $0 == "unset_ssh.sh" ]] ; then | |
ssh ${server} 'rm -rf .ssh' | |
else | |
usage | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment