0

The sshpass programme can automatically enter the ssh password without you having

Is there anything that will do that for a sudo prompt? Like sudopass? e.g. sudopass -p SUDOPASSWORD sudo -i

Ubuntu Linux 18.04 (or 20.04). I am aware you can make sudo not require a password, but I am ssh'ing into a server I don't control, and can't do that.

Amandasaurus
  • 31,471
  • 65
  • 192
  • 253

1 Answers1

2

You can provide an askpass program to sudo by exporting the SUDO_ASKPASS environmental variable, and providing the -A switch to sudo.

The askpass program must provide the password to its standard output (like ssh-askpass normally does). It might worth noting that the content of the SUDO_ASKPASS variable must be the path of the executable, as sudo tries to run the whole value as is was a program. For this reason, you can't use programs with arguments, you have to write a wrapper script if you want to do so.

Lacek
  • 7,233
  • 24
  • 28