Make sure server exists in ~/.ssh/config

Signed-off-by: Jacob Kiers <jacob@alphacomm.nl>
This commit is contained in:
Jacob Kiers 2015-02-02 15:44:56 +01:00
parent b3e4231ae0
commit 9a9d1beb88
1 changed files with 9 additions and 3 deletions

View File

@ -21,13 +21,19 @@ if [ -z "$IP" ]; then
IP=$HOST
fi
echo Adding server to .ssh/config...
cat >> ~/.ssh/config <<EOF
grep "Host $HOST" ~/.ssh/config 2>&1 > /dev/null
if [ 0 -eq $? ]; then
echo $HOST is already in .ssh/config
else
echo Adding server to .ssh/config...
cat >> ~/.ssh/config <<END_OF_HOST
Host $HOST
HostName $IP
User $USER
EOF
END_OF_HOST
fi
echo Copying .ssh directory to $USER@$HOST...
scp -qr $HOME/.ssh/ $HOST: