I have a java application connect to a remote CentOS using ssh connection.
There’s a shell script, in order to execute it, I need to input the password.
[user@**** ~]$ sudo ***
Password:
My question is how to execute the script without prompt .(I can’t modify /etc/sudoers and I also don’t want to use outputStream to send the password.)
The best and much more secure way is to sudo visudo and attach “NOPASSWD:” to get sudo not require a password.
The way in the middle is using the sudo -S parameter, that expect the password coming from standard input instead that from the terminal device.
The worst and less secure way is to pass a clear text password that one could catch even via ps -ef command using “expect” utility (install it, then “man expect”)