Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
deb11:backuppc [2024/03/17 13:30] – [Configuration for Windows 11 running WSL2 or Hosts without fixed IP address] Bernard Condraudeb11:backuppc [2025/09/14 11:56] (current) – [Configuration for Windows 11 running WSL2 or Hosts without fixed IP address] Bernard Condrau
Line 96: Line 96:
  
 ==== Configuration for Windows 10 running WSL1 ==== ==== Configuration for Windows 10 running WSL1 ====
-  - Windows 10: Install [[win10:wsl|Windows Subsystem for Linux]] on Windows 10 hosts, which installs a //Debian// command line layer on top of your Windows 10 installation. Note that WSL1 installes a bridged network connection which receives an IP address in the same subnet as Windows.+  - Windows 10: Install [[win10:wsl|Windows Subsystem for Linux]] on Windows 10 hosts, which installs a //Debian// command line layer on top of your Windows 10 installation.\\ <color red>**WSL1 installs a bridged network connection which receives an IP address in the same subnet as Windows**</color>.
   - Install ssh and rsync:<code>sudo apt install ssh rsync</code>   - Install ssh and rsync:<code>sudo apt install ssh rsync</code>
   - Harden [[deb9:ssh#Settings|SSH]] and restart the service.   - Harden [[deb9:ssh#Settings|SSH]] and restart the service.
Line 104: Line 104:
 %sudo ALL=(ALL:ALL) ALL %sudo ALL=(ALL:ALL) ALL
 backuppc ALL=(root:root) NOPASSWD: /usr/bin/rsync</code> backuppc ALL=(root:root) NOPASSWD: /usr/bin/rsync</code>
 +  - If it's a new machine you are connecting make sure the public key of the host is added to the server and you have connected manually from server to host to add to the ''known_hosts'' file<code></code>
   - Test rsync access as root with the following command from user ''backuppc'' on the BackupPC Server:<code>ssh <host> -p <port> sudo rsync --version</code>   - Test rsync access as root with the following command from user ''backuppc'' on the BackupPC Server:<code>ssh <host> -p <port> sudo rsync --version</code>
 +  - For Windows: start the following program as a task after user login in ''Task Scheduler'':<code>C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe -c "sudo /etc/init.d/ssh start"</code>
   * [[https://superuser.com/questions/1481318/allowing-automatic-command-execution-as-root-on-linux-using-ssh#answer-1483701|Allowing automatic command execution as root on Linux using SSH]]   * [[https://superuser.com/questions/1481318/allowing-automatic-command-execution-as-root-on-linux-using-ssh#answer-1483701|Allowing automatic command execution as root on Linux using SSH]]
   * [[https://man.openbsd.org/OpenBSD-current/man8/sshd.8#AUTHORIZED_KEYS_FILE_FORMAT|authorized_keys]]   * [[https://man.openbsd.org/OpenBSD-current/man8/sshd.8#AUTHORIZED_KEYS_FILE_FORMAT|authorized_keys]]
  
 ==== Configuration for Windows 11 running WSL2 or Hosts without fixed IP address ==== ==== Configuration for Windows 11 running WSL2 or Hosts without fixed IP address ====
-  - Windows 11: Enable [[win10:wsl|Windows Subsystem for Linux]] on Windows 11 hosts as //Windows feature//, then install //Debian// from the Microsoft store. Note that WSL2 installes a NAT'ed network connection and assignes a new IP address on every reboot.+  - Windows 11: Enable [[win10:wsl|Windows Subsystem for Linux]] on Windows 11 hosts as //Windows feature//, then install //Debian// from the Microsoft store.\\ <color red>**WSL2 installs a NAT'ed network connection and assignes a new IP address on every reboot**</color>.
   - Install ssh, autossh and rsync:<code>sudo apt install ssh autossh rsync</code>   - Install ssh, autossh and rsync:<code>sudo apt install ssh autossh rsync</code>
   - Harden [[deb9:ssh#Settings|SSH]] and restart the service.   - Harden [[deb9:ssh#Settings|SSH]] and restart the service.
Line 117: Line 119:
 %sudo ALL=(ALL:ALL) ALL %sudo ALL=(ALL:ALL) ALL
 backuppc ALL=(root:root) NOPASSWD: /usr/bin/rsync</code> backuppc ALL=(root:root) NOPASSWD: /usr/bin/rsync</code>
-  - Establish a ssh connection from host to server with reverse tunneling:<file>autossh -M 0 -f -N -R <reverse_port>:localhost:<ssh_port> host.domain.tld -p <wan_port></file>__Notes__: -M -f are autossh options, all others are ssh options; <reverse_port> is the port you will use to access the host from the server through the reverse ssh tunnel, <ssh_port> is the ssh port on the host, and <wan_port> is the ssh port on the server accessible from the wan.<code></code>+  - Establish a ssh connection from host to server with reverse tunneling:<file>autossh -M 0 -f -N -R <reverse_port>:localhost:<ssh_port> host.domain.tld -p <wan_port></file><color blue>__Note__: -M -f are autossh options, all others are ssh options; <reverse_port> is the port you will use to access the host from the server through the reverse ssh tunnel, <ssh_port> is the ssh port on the host, and <wan_port> is the ssh port on the server accessible from the wan.</color><code></code>
   - Use ''autossh'' instead of ''ssh'' to reestablish the ssh connection if it drops - add the following options in the server's ''sshd_config'' to have ssh drop the connection if unresponsive<code>ClientAliveInterval 60   - Use ''autossh'' instead of ''ssh'' to reestablish the ssh connection if it drops - add the following options in the server's ''sshd_config'' to have ssh drop the connection if unresponsive<code>ClientAliveInterval 60
 ClientAliveCountMax 10</code> ClientAliveCountMax 10</code>
 +  - If it's a new machine you are connecting make sure the public keys are exchanged on host and server and you have connected manually from each side to add both to the ''known_hosts'' file<code></code>
   - Test rsync access as root with the following command from user ''backuppc'' on the BackupPC Server:<code>ssh localhost -p <reverse_port> sudo rsync --version</code>   - Test rsync access as root with the following command from user ''backuppc'' on the BackupPC Server:<code>ssh localhost -p <reverse_port> sudo rsync --version</code>
-  - For Windows: start the following programs as a task after user login in ''Task Scheduler'':<code>C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe -c "sudo /etc/init.d/ssh start" +  - For Windows: start the following programs as a task after user login in ''Task Scheduler'' (sleep 1 second is required to give ''autossh'' time to drop into background before the shell is terminated):<code>C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe -c "sudo /etc/init.d/ssh start" 
-C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe -c "autossh -M <base_port> -N -f -R <reverse_port>:localhost:<ssh_port> host.domain.tld -p <port> && sleep 1"</code>+C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe -c "autossh -M 0 -f -N -R <reverse_port>:localhost:<ssh_port> host.domain.tld -p <wan_port> && sleep 1"</code>
   - Note that these commands work if WSL was installed as Windows feature (e.g. WSL2, Windows 11) and Debian through the Microsoft Store, otherwise you need to find the location of ''bash.exe''. In addition you need to allow <user> to execute ''/etc/init.d/ssh'' as root without password.<code></code>   - Note that these commands work if WSL was installed as Windows feature (e.g. WSL2, Windows 11) and Debian through the Microsoft Store, otherwise you need to find the location of ''bash.exe''. In addition you need to allow <user> to execute ''/etc/init.d/ssh'' as root without password.<code></code>
   - The BackupPC host config file needs to backup ''localhost'' on port <reverse_port>.   - The BackupPC host config file needs to backup ''localhost'' on port <reverse_port>.
 +
 +=== Reverse Ports ===
 +  * Hera: 60022
 +  * Vulcan: 60322
 +  * Heracles: 60422
 +  * Cassandra: 60522
  
 === Links === === Links ===
   * [[https://serverfault.com/questions/534229/autossh-in-background-does-not-work#answer-972141|autossh in background]]   * [[https://serverfault.com/questions/534229/autossh-in-background-does-not-work#answer-972141|autossh in background]]
   * [[https://superuser.com/questions/1756597/remotely-access-pc-behind-firewall-from-my-dynamic-ip-pc-via-a-static-ip-vps#answers|Remotely access pc behind firewall from my dynamic-ip pc via a static-ip VPS]]   * [[https://superuser.com/questions/1756597/remotely-access-pc-behind-firewall-from-my-dynamic-ip-pc-via-a-static-ip-vps#answers|Remotely access pc behind firewall from my dynamic-ip pc via a static-ip VPS]]
 +  * [[deb11:autossh_public|Public explanation]]
  
 ==== Configuration on Synology DSM6 Hosts ==== ==== Configuration on Synology DSM6 Hosts ====
Line 186: Line 196:
   * [[https://kifarunix.com/backup-windows-system-with-backuppc-using-rsyncd/|Backup Windows System with BackupPC Using Rsyncd]]   * [[https://kifarunix.com/backup-windows-system-with-backuppc-using-rsyncd/|Backup Windows System with BackupPC Using Rsyncd]]
   * [[https://github.com/backuppc/cygwin-rsyncd|cygwin-rsyncd: Rsyncd for Cygwin]]   * [[https://github.com/backuppc/cygwin-rsyncd|cygwin-rsyncd: Rsyncd for Cygwin]]
 +  * [[https://www.systemajik.com/setting-up-backuppc-on-windows/|Setting Up BackupPC on Windows (rsyncd)]]
   * [[http://no-sheds.blogspot.com/2017/05/setting-up-windows-backuppc-client.html|Setting up a Windows Backuppc Client using Rsync/Cygwin]]   * [[http://no-sheds.blogspot.com/2017/05/setting-up-windows-backuppc-client.html|Setting up a Windows Backuppc Client using Rsync/Cygwin]]
   * [[https://winscp.net/eng/docs/guide_windows_openssh_server|Installing SFTP/SSH Server on Windows using OpenSSH]]   * [[https://winscp.net/eng/docs/guide_windows_openssh_server|Installing SFTP/SSH Server on Windows using OpenSSH]]