Created
July 11, 2016 04:37
-
-
Save WalterInSH/b17917ab5e44448eb356ce24fc734311 to your computer and use it in GitHub Desktop.
add a ssh key on servers
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/sh | |
SSH_KEY="key" | |
if [ -f ~/.ssh/authorized_keys ] && [ $(grep -c "$SSH_KEY" ~/.ssh/authorized_keys) -gt 0 ]; then | |
echo "ssh key exists" | |
else | |
if [ -f ~/.ssh/authorized_keys ]; then | |
cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys.bak | |
fi | |
printf "\n$SSH_KEY" >> ~/.ssh/authorized_keys | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment