What I am trying to do (in bash) is:
for i in <host1> <host2> ... <hostN>; do ssh leroy@$i "sudo -i; grep Jan\ 15 /var/log/auth.log" > $i;done
to get just today's entries from these hosts auth.logs and aggregate them on my local filesystem. sudo is required because auth.log only allows root access. Using the root user isn't an option because that account is disabled. Using key-based authentication isn't an option because the systems implement 2FA (key and password).
When I do the above (after initial authentication) I get
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
I have tried various parameters to the -S option and included the -M option, nothing works. Searching the web doesn't surface anything with this exact situation.
parallel-ssh
. – FelixJN Jan 16 '22 at 00:36