Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to write a little bash script which could sudo to a super user without manually typing in the password from the keyboard, I need this script read password from my bash script itself. But I couldn't make it work. Could anyone here to help me out?
My bash script is as below:
********************************
#!/bin/bash
echo 'about to sue dough'
sudo su - ebba
< "password"
echo 'this did it'
********************************
I want to write a little bash script which could sudo to a super user without manually typing in the password
No you don't.
This is a bad question. You would never want to do this, ever. I forgive you. Here's what you're gonna do. Abandon this thread, make a new one. Name it something describing the problem behind this problem and let someone else suggest what you should actually do.
But yes, I need such a script. Basically, I want input the password from inside the script itself, instead of type in from keyboard. Anything wrong with this initialtive? I need this for my batch automation script.
And even if you did succeed in giving the password that way, note that it would be stored into the file in clear text, which is a serious security flaw as such.
Indeed you can use NOPASSWD in /etc/sudoers configuration file for those commands you want to be able to do without passwords asked. I don't recommend this either unless it's absolutely necessary, but it's definitely better than saving your password in clear text into some place..
Thanks for all the comments. Yes, I realized now that I did ask a not proper question. But still worth to do so as I got it straighten out and won't ask it again next time.
I'm going to ask the sys admin to bypass the password for my user.
Thank you for all again! Nice forum here. This is my first post indeed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.