Skip to content

Instantly share code, notes, and snippets.

@WalterInSH
WalterInSH / add-ssh-key.sh
Created July 11, 2016 04:37
add a ssh key on servers
#!/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