0
1
I do not have sudo su
over a username, however I have its password. I want to have an script that passes the password and gives me an interactive bash.
I have tried this:
echo mypassword | su - otherusr
Password: Last login: Wed Jul 25 12:09:38 COT 2018
[myuser@myserver ~]$
It returns me to myuser and I do not have an interactive bash with the other user.
I tried also:
echo mypassword | su -c "/bin/bash" - otherusr
echo mypassword | su -s "/bin/bash" - otherusr
echo mypassword | su -c "/bin/bash -i" - otherusr
Password: bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
bash-4.2$ exit
How can I do that? I want to create an script that returns me an interactive bash session with another user; not just execute a command with another user.
It looks like you're working in some super-limited shell, and it isn't piping your password. Try su, and type the password normally?
Also, you typically shouldn't use this method to log in, as then your password is logged in the bash logs. That's usually a severe security concern. If you're gonna use this method, might as well add
nopasswd
tosudoers
– Chris – 2018-07-25T17:46:38.000Why not
su - otherusr
and type the password if your going interactive anyway. It looks like you're already in a shell. – Hogstrom – 2018-07-25T18:28:32.527