1

I am using the following command to skip the 'password' check using 'echo' in ubuntu,

echo $password | sudo -S apt-get install -y default-jdk

I am using the following command to skip the 'password' check using 'echo' in centos,

echo $password | yum -S -y install python-pip

But the -S and echo is not working in CentOS rather, It is asking me to enter the password again. What is the way to skip asking for password using echo Or anything wrong in this command?

NOTE: I can't use SSH-KEY

EDITED: To make it clear,

1)I need to deliver a script to my customer, where the script will install python-pip as one of the part. The customer will provide the password as input for that script so I don't want the customer to enter the password during the execution of script.

(i.e) I need to install the python-pip in the same machine without asking the user to enter the password. So as I tried in ubuntu I used the echo $password with -S, So I dont have any way to edit the sudoers also.

So now Is there a way like echo $password / -S in centos?

closed as off-topic by roaima, Jeff Schaller, Rui F Ribeiro, forcefsck, G-Man May 7 '18 at 1:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – roaima, Jeff Schaller, Rui F Ribeiro, forcefsck, G-Man

  • 3
    Are you sure yum support -S? Why you not use sudo for CentOS? – Romeo Ninov May 6 '18 at 4:55
  • Could you update me the sample SUDO command form this? If we are not using -S what is the command to skip the password in CentOS? – Harry May 6 '18 at 4:56
  • 3
    @Harry yum doesn't support that option. If you want passwordless privilege elevation either install and configure sudo or rig su not to ask for a password. – dsstorefile1 May 6 '18 at 5:26
  • @dsstorefile1 Could you give an example with sudo in centos for not to ask for a password Thanks, If you could explain for installing python-pip without a password, It would be Great. – Harry May 6 '18 at 5:40
  • 1
    Also, do not cross post. superuser.com/q/1320141/873319 – dsstorefile1 May 6 '18 at 6:00
1

I don’t see -S in yum’s man page.  Do you have some reason to believe that it means something?

Maybe you mean echo $password | sudo -S yum -y install python-pip?

echo $password is bad security.  Can you set up /etc/sudoers to allow the user to run apt-get and yum without asking for a password?

  • this worked for me – Harry May 7 '18 at 5:19
0

I would suggest you run your entire script with sudo so that everything within runs as root.

For most of the operations you could deescalate to an unprivileged user for performing non-critical tasks like in the form of sudo -u nobody command

Not the answer you're looking for? Browse other questions tagged or ask your own question.