Add openssh meta to add server node to known hosts
Related: PROD-25696
Change-Id: Ib1de419d078c53ba6bba988eb7dc08165f3c0141
diff --git a/xtrabackup/files/innobackupex-client-restore-call.sh b/xtrabackup/files/innobackupex-client-restore-call.sh
index 3adafd5..e318d5b 100644
--- a/xtrabackup/files/innobackupex-client-restore-call.sh
+++ b/xtrabackup/files/innobackupex-client-restore-call.sh
@@ -16,12 +16,9 @@
local LOGDIR="/var/log/backups"
local scpLog="/var/log/backups/innobackupex-restore-scp.log"
mkdir -p $LOGDIR
- echo "Adding ssh-key of remote host to known_hosts"
- ssh-keyscan ${CLIENT_TARGET_HOST} >> ~/.ssh/known_hosts 2>&1 | >> $scpLog
echo "Calling /usr/local/bin/innobackupex-restore.sh $REMOTEBACKUPPATH and getting the backup files from remote host"
REMOTEBACKUPPATH="$(ssh xtrabackup@${CLIENT_TARGET_HOST} "/bin/bash /usr/local/bin/innobackupex-restore-call.sh ${CLIENT_RESTORE_FULL_LATEST}")"
/usr/local/bin/innobackupex-restore.sh $REMOTEBACKUPPATH
- ssh-keygen -R ${CLIENT_TARGET_HOST} 2>&1 | > $scpLog
}
function backup_local(){
diff --git a/xtrabackup/files/innobackupex-client-runner.sh b/xtrabackup/files/innobackupex-client-runner.sh
index b287300..7a70e2d 100644
--- a/xtrabackup/files/innobackupex-client-runner.sh
+++ b/xtrabackup/files/innobackupex-client-runner.sh
@@ -204,11 +204,6 @@
# rsync just the new or modified backup files
if [ ! -z "$SERVERBACKUPHOST" ]; then
- echo "Adding ssh-key of remote host to known_hosts"
- if [ -f ~/.ssh/known_hosts ]; then
- ssh-keygen -R $SERVERBACKUPHOST 2>&1 | tee $rsyncLog
- fi
- ssh-keyscan $SERVERBACKUPHOST >> ~/.ssh/known_hosts 2>&1 | tee $rsyncLog
echo "Rsyncing files to remote host"
/usr/bin/rsync -rhtPpv --rsync-path=rsync --progress $BACKUPDIR/* -e ssh xtrabackup@$SERVERBACKUPHOST:$SERVERBACKUPDIR 2>&1 | tee $rsyncLog
diff --git a/xtrabackup/meta/openssh.yml b/xtrabackup/meta/openssh.yml
new file mode 100644
index 0000000..a3e8eca
--- /dev/null
+++ b/xtrabackup/meta/openssh.yml
@@ -0,0 +1,11 @@
+{%- from "xtrabackup/map.jinja" import client with context %}
+{%- if client.get('enabled', False) %}
+user:
+ xtrabackup:
+ enabled: true
+ user: ${linux:system:user:xtrabackup}
+ known_hosts:
+ - name: {{ client.target.host }}
+ type: ssh-rsa
+ public_key: ${_param:backup_public_key}
+{%- endif %}
\ No newline at end of file