#!/bin/bash #creat ssh keys and install them for backup #we need to have the backup user created on the host, with permission to access the backup directories BKHOST=sv.cfaw.info BKUSER=backuser #start in /root mkdir -p .ssh; chmod 700 .ssh; cd .ssh echo " host sv-backup hostname sv.cfaw.info user $BKUSER identityfile /root/.ssh/backupk compression yes protocol 2 port 22 " > config #make sure that the following permissions are in place chmod 600 config ssh-keygen -f backupk -t rsa -C "backupkey" -N "" PUBKEY=`cat backupk.pub` ssh $BKUSER@$BKHOST "mkdir -p ~$BKUSER/.ssh; chmod 700 ~$BKUSER/.ssh; echo \"$PUBKEY\" >> ~$BKUSER/.ssh/authorized_keys; chmod 600 ~$BKUSER/.ssh/authorized_keys" #log into the host and check permissions #test with ssh sv-backup #lock down authorized_keys on the server by restricting from, command etc.