I'd do this with Ansible. You can create a inventory file which includes your servers like this:
$ cat inventory
Then run an Ansible ad-hoc command like this:
$ ansible -i inventory -m shell -a "cat /var/log/QPKS/qpk" all
If you have to provide access to this file via sudo add the
-b switch to
ansible. If you need to provide a password for
-K. To connect to the remote server as an alternative user use
run operations with become (does not imply password prompting)
ask for privilege escalation password
-u REMOTE_USER, --user REMOTE_USER
connect as this user (default=None)
In the past I've used other tools to do this same thing. the first link shows doing a similar thing using
pssh. The 2nd link shows how you can use
pssh to propagate your SSH key across a bunch of servers the 1st time, when all you have is username/password access to a set of servers, and don't want to key your password in dozens of times to push your SSH key out initially.
Once your SSH key has been dispersed, the above looping you're having to do goes away since you'll have SSH key access set up, eliminating the need to key in your password.