This plugin allows you to automatically back up important files on your Pwnagotchi device. It supports both local and remote backups via rsync over SSH.
- Automatic Backups: Periodically backs up files to a local or remote server.
- Local and Remote Backup: Specify a local directory and a remote SSH server to store backups.
- Architecture-Aware: Detects whether your system is 32-bit or 64-bit and adjusts the backup files accordingly.
- Pwnagotchi: Installed on a Raspberry Pi.
- SSH Key: Required for remote backups.
- Internet Access: To download the plugin and perform remote backups.
To perform remote backups, you’ll need to create an SSH key that the Pwnagotchi can use to connect to the remote server.
-
Generate the SSH key (on your Pwnagotchi):
ssh-keygen -t rsa -b 4096 -f ~/.ssh/pwnagotchi_backup_key -N ""
-
Copy the SSH public key to your remote server:
ssh-copy-id -i ~/.ssh/pwnagotchi_backup_key.pub user@remotehost
Replaceuser@remotehost
with your remote server's username and IP address.
Use the following command to display the key:
cat ~/.ssh/pwnagotchi_backup_key.pub
Make sure to copy the output to your clipboard.
Add the SSH key (~/.ssh/pwnagotchi_backup_key.pub
) to your GitHub account under Settings > SSH and GPG keys.
Then
nano ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/pwnagotchi_backup_key
And finally run these commands
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/pwnagotchi_backup_key
ssh -T [email protected]
Result should be
Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
Use the following command to display the key:
cat ~/.ssh/pwnagotchi_backup_key.pub
Make sure to copy the output to your clipboard.
- Go to GitHub and log in to your account.
- Click the + icon in the upper right corner and select New repository.
- Enter a repository name (e.g., Backup).
- Select Private to keep your repository secure.
- Click Create repository.
Download the installation script to your Pwnagotchi:
wget https://github.com/wpa-2/pwny_backup/raw/main/install_autobackup.sh -O install_autobackup.sh
Make the script executable:
chmod +x install_autobackup.sh
Run the installation script:
sudo ./install_autobackup.sh
The script will:
- Check the permissions of your SSH key.
- Prompt for the local and remote backup paths.
- Test your SSH connection to the remote server.
- Download the
autobackup.py
plugin and install it. - Update the Pwnagotchi configuration file with the required plugin configuration.
During the installation, you'll be prompted to enter:
- Local Backup Path: Directory on the Pwnagotchi where local backups will be stored.
- Remote Backup: The SSH connection string for the remote server (e.g.,
user@remotehost:/path/to/backup
).
Autobackup Plugin Configuration
main.plugins.autobackup.github_repo = "[email protected]:username/repository.git"
main.plugins.autobackup.github_backup_dir = "Backups"
main.plugins.autobackup.remote_backup = "user@LOCALIP:/path/to/folder/,/home/pi/.ssh/pwnagotchi_backup_key"
main.plugins.autobackup.enabled = true
main.plugins.autobackup.interval = 1 # Backup every 1 hour
main.plugins.autobackup.max_tries = 3
main.plugins.autobackup.local_backup_path = "/home/pi/backup/"
Restart Pwnagotchi to apply the changes:
sudo systemctl restart pwnagotchi
Check the logs to verify the plugin is running:
pwnlog
You should see log entries indicating that the backup process is scheduled and running.
The backup interval is set in the configuration file. Adjust it based on your needs; for example, a 1-hour interval might be suitable for regular backups, while longer intervals may suffice for less critical data.
Ensure your SSH keys are kept secure. Do not share your private key, and consider using passphrases for added security.
If you encounter issues, please open an issue on the GitHub repository.
- Version x.0: Initial release.
-
SSH Connection Issues: Ensure that the SSH key has been properly configured and that the Pwnagotchi can connect to the remote server without needing a password:
ssh -i /home/pi/.ssh/pwnagotchi_backup_key user@remotehost
ssh -T [email protected]
-
Permissions: Ensure the SSH key file has the correct permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/pwnagotchi_backup_key
chmod 644 ~/.ssh/pwnagotchi_backup_key.pub
-
Logs: Check the Pwnagotchi logs for any errors or issues with the backup process:
pwnlog
Some times this shows as an error (not really an issue if your using pwny a lot and its not sat in manu mode)
14:21:43 [ERROR] AUTO_BACKUP: Git command 'cd /home/pi/backup/Backups && git commit -m 'Backup on 2024-09-21 14:21:43.157731'' failed with exit code 1
Just means the backup hasnt changed and theres nothing new to upload, i need to fix that at some point.