This method is ideal when:
- You’re backing up a DirectAdmin account to a backup server.
- Password authentication is disabled on the source server.
rsyncis not available or not permitted.
In this setup, the backup server pulls data from the source server using scp over SSH with key-based authentication.
π§° Step 1: Generate SSH Key Pair on the Backup Server
On your backup server, generate a key pair:
ssh-keygen -t rsa -b 4096 -C "backupuser@example-backup.com"
- Press
Enterthrough all prompts to accept default location (/root/.ssh/id_rsa). - Leave the passphrase blank unless you want additional security.
π€ Step 2: Copy Public Key to Source Server
Copy the contents of /root/.ssh/id_rsa.pub (from the backup server) to the source server.
On the source server (logged in as the user to back up):
mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys
- Paste the contents of
id_rsa.pubinto the file.
Set correct permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
π Step 3: Test SSH Access
From the backup server, test the connection:
ssh webuser@example-source.com
- You should be logged in without entering a password.
- If prompted for a passphrase, ensure you created the key without one, or use an agent like
ssh-agent.
π¦ Step 4: Pull Backup Data Using SCP
Now, from the backup server, pull the data:
scp -r webuser@example-source.com:/home/webuser/backups/* /home/backupuser/backups/
Breakdown:
webuser@example-source.comβ SSH login for the source server./home/webuser/backups/*β Folder to pull (absolute or relative to home)./home/backupuser/backups/β Destination directory on the backup server.
β Make sure the destination directory exists on the backup server:
mkdir -p /home/backupuser/backups/
β Summary
This method offers a secure, password-less, and automated way to pull backup data from a source serverβideal when using cPanel or DirectAdmin or in environments where rsync is disallowed and password logins are blocked.
