sudo doesn't work in .bash_profile for chroot user
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
sudo doesn't work in .bash_profile for chroot user
This appears to be a complicated issue, so I'm hoping someone has run into this before or can point me in the right direction.
for the sake of this example lets say the user account is test and the command I'm trying to run is a small c program called chdir.
I have a user account that logs into the chroot jail using ssh. That account runs a bunch of commands in the .bash_profile file. One of the commands needs to run under sudo. If I delete the .bash_profile file and just get to a shell prompt, I can run sudo ... and it works.
If I try the same command in the .bash_profile it comes back with.
Sorry, try again.
Sorry, try again.
Sorry, try again.
/chbin/sudo: 3 incorrect password attempts
(Never once did it give me an option to enter a password)
sudoers has
test ALL=(ALL) NOPASSWD: /bin/chdir
Since this is a jail I've duplicated the sudoers file in the normal /etc and the chroot/etc folders. I've also duplicated the /etc passwd and shadow files.
looking in the var/log/secure I see:
May 31 21:02:37 myhost sudo: test : 3 incorrect password attempts ; TTY=pts/3 ; PWD=/y/tmp/off000 ; USER=root ; COMMAND=chdir off000 /y/tmp/off000
I'm not sure where to go next with this, so I hope someone in the know can help.
I finally figured it out. I'm running Redhat and I needed to set up a sudo config file in the pam.d folder. I found a copy of the (sudo) sample.pam file and everything is moving forward again. None of the error messages gave me any clue that this was a pam problem. Sigh! Thanks for trying to lend a hand.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.