When I use chef knife solo
with a non-root user with sudo access, it always asks me that user's password. However, I have turned off password access to that server.
$ bundle exec knife solo cook supersecretuser@productionserver -VV
Starting 'Run'
Running Chef on productionserver...
Checking Chef version...
DEBUG: Initial command sudo chef-solo --version 2>/dev/null | awk '$1 == "Chef:" {print $2}'
DEBUG: Initial command sudo -V
DEBUG: Running processed command sudo -V
DEBUG: sudo -V stdout: Sudo version 1.8.9p5
DEBUG: sudo -V stdout: Sudoers policy plugin version 1.8.9p5
Sudoers file grammar version 43
DEBUG: sudo -V stdout: Sudoers I/O plugin version 1.8.9p5
DEBUG: Running processed command sudo -E -p 'knife sudo password: ' chef-solo --version 2>/dev/null | awk '$1 == "Chef:" {print $2}'
Enter the password for supersecretuser@productionserver:
I've added my ssh key to the server and am able to ssh into that server with ssh supersecretuser@productionserver
without needing a password.
I have used chef knife solo
on my staging server with the root user and it works fine.
I've tried explicitly passing my ssh key using the -i
option, chef knife solo cook supersecretuser@productionserver -i ~/.ssh/id_rsa.pub
and knife solo didn't seem to use that. Any ideas on what to try next?
Note: I am showing cook
because that's where I'm at. I did a prepare
and it worked because I hadn't turned off password access yet - that happened with my first cook
- so I was able to just enter the password.
You messing between ssh and sudo, check your sudoers file for the supersecretuser entry it should looks like:
#Vagrant entry to allow sudo from vagrant
vagrant ALL=(ALL) NOPASSWD: ALL
Here allowing vagrant user to sudo any command without password.