feat: known hosts
This commit is contained in:
parent
91958cf969
commit
15d48f3d55
1 changed files with 15 additions and 4 deletions
19
backup.sh
19
backup.sh
|
@ -6,14 +6,25 @@ test -n "${BORG_PASSPHRASE}"
|
||||||
test -n "${DEST}"
|
test -n "${DEST}"
|
||||||
test -n "${SSH_ALIAS}"
|
test -n "${SSH_ALIAS}"
|
||||||
|
|
||||||
|
# Defaults
|
||||||
|
SSH_PORT="${SSH_PORT:-22}"
|
||||||
|
SSH_SERVER="${SSH_SERVER:-${SSH_ALIAS}}"
|
||||||
|
SSH_USER="${SSH_USER:-root}"
|
||||||
|
|
||||||
|
umask 077
|
||||||
|
|
||||||
DATE="$(date +%F)"
|
DATE="$(date +%F)"
|
||||||
ORIG=/srv/data
|
ORIG=/srv/data
|
||||||
|
|
||||||
if ! grep -q "${SSH_ALIAS}" /root/.ssh/config ; then
|
if ! grep -q "${SSH_ALIAS}" /root/.ssh/config ; then
|
||||||
echo "Host ${SSH_ALIAS}" >> /root/.ssh/config
|
echo "Host ${SSH_ALIAS}" >> /root/.ssh/config
|
||||||
echo " Port ${SSH_PORT:-22}" >> /root/.ssh/config
|
echo " Port ${SSH_PORT}" >> /root/.ssh/config
|
||||||
echo " HostName ${SSH_SERVER:-${SSH_ALIAS}}" >> /root/.ssh/config
|
echo " HostName ${SSH_SERVER}" >> /root/.ssh/config
|
||||||
echo " User ${SSH_USER:-root}" >> /root/.ssh/config
|
echo " User ${SSH_USER}" >> /root/.ssh/config
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! ssh-keygen -F "[${SSH_SERVER}]:${SSH_PORT}"; then
|
||||||
|
echo "${SSH_KNOWN_HOSTS}" >> /root/.ssh/known_hosts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh -fN ${SSH_ALIAS}
|
ssh -fN ${SSH_ALIAS}
|
||||||
|
|
Loading…
Reference in a new issue