feat: known hosts

This commit is contained in:
f 2023-05-20 12:05:39 -03:00
parent 91958cf969
commit 15d48f3d55

View file

@ -6,14 +6,25 @@ test -n "${BORG_PASSPHRASE}"
test -n "${DEST}"
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)"
ORIG=/srv/data
if ! grep -q "${SSH_ALIAS}" /root/.ssh/config ; then
echo "Host ${SSH_ALIAS}" >> /root/.ssh/config
echo " Port ${SSH_PORT:-22}" >> /root/.ssh/config
echo " HostName ${SSH_SERVER:-${SSH_ALIAS}}" >> /root/.ssh/config
echo " User ${SSH_USER:-root}" >> /root/.ssh/config
echo "Host ${SSH_ALIAS}" >> /root/.ssh/config
echo " Port ${SSH_PORT}" >> /root/.ssh/config
echo " HostName ${SSH_SERVER}" >> /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
ssh -fN ${SSH_ALIAS}