I am new to Linux. I have created 2 Azure VMs based on Cent OS 7.4 for learning purposes. For the first machine, I provided SSH keys during the create procedure. I use the private key via putty and login to the box. For the second box, I provided password and use this for logging in. Everything works as expected on the second box as well. Now to change it, I added the SSH keys for the second box as well. But whenever I run a command with "sudo", the second box asks for password where as first one does not (obviously I never provided password for it and works as expected). I have verified sudoers file, sshd_config file, bashrc and other files. They all match. What other config file I need to verify to see the differences between the machines? The other question is If I have to add a password for first machine, what config files I need to be looking at?

1 Answer 1


The sudo command is configured by the file /etc/sudoers, which, in CentOS 7, also includes all config files under the /etc/sudoers.d directory. Some cloudinit script will add the main/first created user to the wheel group and enable the option

%wheel        ALL=(ALL)       NOPASSWD: ALL

for passwordless commands for any user in the wheel group.

Check your user ID and group IDs with the id command, and see if there is any reference to it/them in the /etc/sudoers.d directory or the /etc/sudoers file.

  • Thanks. I had checked the wheel group. I had set wheel group to use the password. So I knew that was not the answer. The hint was sudoers.d directory. There is a reference to my user id with NOPASSWD:ALL. Your help is greatly appreciated.
    – B K
    Feb 12, 2018 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .