Facing difficutly while using pssh command with sudo option

I have a scenario where, i would like to pull the version of particular service installed. which requires to be run on multiple nodes installed. so i thought to use pssh.

i tried to use the following command,

pssh -i -v -H "host1, host2" -A -l user -X "sudo su - perl -c "perl -v""

While issuing the above command i get the following error,

Stderr: sudo: no tty present and no askpass program specified

To fix such error, you need to grant the permission to user to use that pssh command without prompting for password. Follow below steps.

  1. Go to terminal and type the following command.

    $ sudo visudo

  2. Next edit the visudo file and add the following line at the bottom of the file.

    username ALL = NOPASSWD: /full-location-of-pssh-command

    That’s it! the above line will allow user to run pssh command without being prompted for password.

I have a large amount of servers for which this would be more difficult.
How do i specify tty in pssh command ?