knife bootstrap command without prompting password
Solution 1
This is how I made this work.
echo <SSH_PASSWORD> | knife bootstrap <IP_ADDRESS> -x <USER_NAME> -P <PASSWORD> --sudo
Solution 2
Looking through the doc this may be the parameter you need:
--use-sudo-password
Although the documentation seems to imply that the password that that will be used is the same for the ssh operation, I don't know if that will be sufficient in your case.
Reference: https://docs.chef.io/knife_bootstrap.html#knife-bootstrap-options
Solution 3
If you want to avoid using passwords , you could set up the ssh keys of your workstation on the chef-node and run the
knife bootstrap yourclient.domain.com -x <USER_NAME> -i ~/.ssh/id_rsa -N client1 --sudo
HRM
Application Developer Mobile apps (iPhone) | Desktop apps (Windows) | Web apps (HTML/JS/CSS with Angular) "Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it." Steve Jobs
Updated on August 06, 2022Comments
-
HRM over 1 year
I am trying to write a bash script which contains the command for bootstrapping a Ubuntu client node using
knife
command. When I execute the script, theknife
command was asking the sudo password of client node and once i type the password, it works as expected. But I am looking for an automated way without prompting password. Here is the command I used for bootstrapping.knife bootstrap <IP_ADDRESS> -x <USER_NAME> -P <PASSWORD> --sudo
After checking, knife bootstrap document, I have tried giving the ssh-password also like below, but with same result.
knife bootstrap <IP_ADDRESS> --ssh-user <USER_NAME> --ssh-password <PASSWORD> --sudo
What may be wrong with this command. I am expecting the knife command to automatically login to the client and bootstrap, but its asking like,
<IP_ADDRESS> knife sudo password: Enter your password:
Any ideas??
-
HRM over 10 yearsOops..Its a typo error. corrected..I used --ssh-password only. The command is working, only prob is that, its prompting for password.
-
slayedbylucifer over 10 yearsWhat you are doing seems to be correct. I checked docs.opscode.com/install_bootstrap.html and see that it also asks for the password even though it is already supplied. Were you able to do it without password in the past? Or is this something your trying to do for hte 1st time?
-
slayedbylucifer over 10 yearsI always bootstrap from the node itself so never had to follow this process. Let me know if you find something which resolves your issues.
-
HRM over 10 yearsNope...not working.I have added NOPASSWD for admin, but still the same. But i guess, this wont be the correct solution even if it works..coz we need to configure these things in client node, before bootstrapping, rt? that kind of tricks are my final option..
-
Mark O'Connor over 10 yearsIt worries me when you say you added "NOPASSWD" for admin..... Are you also bootstrapping chef using the user "admin"?.... This will work. It may be inconvenient but it has to happen on the node you are connecting to. Allowing a client to disable a security feature from a remote connection would be a bad idea. Think of sudo configuration like the configuration you have to setup for sshd. Create your security policy and bake it into your image.
-
spuder about 9 yearsIf you do this, make sure you turn off your bash history, otherwise people could retrieve your password. stackoverflow.com/questions/6475524/…
-
Anup Singh almost 8 yearsknife bootstrap -N <NoteName> <NoteIP> --sudo --use-sudo-password <pass> --ssh-user <sshuser> -P <sshpassword> -y --secret-file encrypted_data_bag_secret -r 'role[Myrole]'