Knife bootstrap command without password hint

I am trying to write a bash script that contains a command to bootstrap an Ubuntu node client using the knife command. When I execute the script command, the knife command requested the sudo password for the node client, and as soon as I type in the password, it works as expected. But I'm looking for an automatic path without asking for a password. Here is the command I used to bootstrap.

 knife bootstrap <IP_ADDRESS> -x <USER_NAME> -P <PASSWORD> --sudo 

After checking the boot knife document , I tried to provide an ssh password, as shown below, but with the same result.

 knife bootstrap <IP_ADDRESS> --ssh-user <USER_NAME> --ssh-password <PASSWORD> --sudo 

What could be wrong with this command. I expect the knife command to automatically log in with the client and bootstrap, but its request, for example,

 <IP_ADDRESS> knife sudo password: Enter your password: 

Any ideas?

+4
source share
7 answers

This is how I did this work.

 echo <SSH_PASSWORD> | knife bootstrap <IP_ADDRESS> -x <USER_NAME> -P <PASSWORD> --sudo 
+1
source

Looking through the document, this may be the parameter you need:

 --use-sudo-password 

Although the documentation seems to imply that the password that will be used will be the same for the ssh operation, I don't know if that will be enough in your case.

Link: https://docs.chef.io/knife_bootstrap.html#knife-bootstrap-options

+5
source

If you want to avoid using passwords, you can configure the ssh keys of your workstation on the chef node and run

 knife bootstrap yourclient.domain.com -x <USER_NAME> -i ~/.ssh/id_rsa -N client1 --sudo 
+3
source

I see a typo in your team

it should be --ssh-password

you have --sh-password

0
source

Check the NOPASSWD parameter in the / etc / sudoers file. This configures sudo to suppress password verification.

0
source

Two types of authentication occur:

  • SSH connection (can be via key or password)
  • Authentication sudo (usually requires a password).

When you boot the machine first, I don’t think you can avoid the need to use a sudo password.

I saw Ruby code that can pass the sudo password over the SSH connection (so the user does not need to enter it in the middle of the command), but I don’t think the knife has that built-in.

0
source

It needs to be used this way (worked for me)

 knife bootstrap $ipaddr --ssh-user $userid --ssh-password $pswd --node-name $hostname --sudo --use-sudo-password -P $pswd 

--use-sudo-password You must also specify a password for this option, as well as for --ssh-password.

0
source

Source: https://habr.com/ru/post/1498878/


All Articles