I'd like to backup the package list(dpkg) of some remote computers to a backup server: all of them running Debian. I already configured the rsa key to login remotely as root on the other computers without authentication. How can I run a command like dpkg --get-selections > file on the remote computers to save the package list, so my backup server can copy those files?
run remote command to save debian package list
debian;backup;command;remote;dpkg
Put all your hostnames in a file, each on a separate line, then ...for h in $(cat <file>); do ssh $h dpkg --get-selections >/tmp/$h.dpkg; done