I am currently working on a java application to get "su -" access to a Linux host. I already know the password, but I want to be able to execute the "su -" command from a bash script and have the command saved to the history. I know that it is bad practice and a security risk, but it is apart of the design of my application. I have tried many variations though, and although people have said they work, I have yet to find one that works.
Tried actions:
echo "password" | su -
su <user> -p <password>
sudo -S su
I have tried many more but non of them seem to work. All help is appreciated. Thanks
P.S I am using the JSCH library, so I am also looking into that as a possible answer.