I have debootstraped version of wheezy on my Archlinux machine and would like to change it's root password:echo root:toor | chpasswd --root /home/containers/wheezy/However I get an error:chpasswd: PAM: Permission deniedWorks fine on my local root user (without --root option).The man page clearly states the following:-R, --root CHROOT_DIR  Apply changes in the CHROOT_DIR directory and use the   configuration files from the CHROOT_DIR directory.So what am I doing wrong? And how does PAM get involved anyway? Other methods to do this?EDIT# echo root:toor | sudo strace -f -efile,execve chpasswd --root /home/containers/wheezy/Below is the output where chpasswd starts complaining.open(/usr/share/locale/locale.alias, O_RDONLY|O_CLOEXEC) = 3open(/usr/share/locale/en_GB.UTF-8/LC_MESSAGES/Linux-PAM.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en_GB.utf8/LC_MESSAGES/Linux-PAM.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en_GB/LC_MESSAGES/Linux-PAM.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en.UTF-8/LC_MESSAGES/Linux-PAM.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en.utf8/LC_MESSAGES/Linux-PAM.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en/LC_MESSAGES/Linux-PAM.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en_GB.UTF-8/LC_MESSAGES/shadow.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en_GB.utf8/LC_MESSAGES/shadow.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en_GB/LC_MESSAGES/shadow.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en.UTF-8/LC_MESSAGES/shadow.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en.utf8/LC_MESSAGES/shadow.mo, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/en/LC_MESSAGES/shadow.mo, O_RDONLY) = -1 ENOENT (No such file or directory)chpasswd: PAM: Permission denied+++ exited with 1 +++EDIT2I have found that the files chpasswd is expecting on the target container can be found for many other languages except English:# find /usr/share/locale/ -iname '*Linux-PAM.mo*'/usr/share/locale/hu/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/zh_CN/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/it/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/zu/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/ko/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/or/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/nl/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/sk/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/ja/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/da/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/uk/LC_MESSAGES/Linux-PAM.mo.../usr/share/locale/pt_BR/LC_MESSAGES/Linux-PAM.mo/usr/share/locale/ta/LC_MESSAGES/Linux-PAM.moNote: en_GB which chpasswd is expecting might be equal to uk on the target container?..I've tried to reinstall packages which seem to have required files:apt-get install --reinstall libpam-runtime login locales locales-allBut that didn't help at all.EDIT3When I run strace on the target container it is not looking for these files:# echo root:toor2 | strace -f -e open chpasswd --root /open(/etc/ld.so.cache, O_RDONLY)      = 3open(/lib/x86_64-linux-gnu/libpam.so.0, O_RDONLY) = 3open(/lib/x86_64-linux-gnu/libpam_misc.so.0, O_RDONLY) = 3open(/lib/x86_64-linux-gnu/libselinux.so.1, O_RDONLY) = 3open(/lib/x86_64-linux-gnu/libcrypt.so.1, O_RDONLY) = 3open(/lib/x86_64-linux-gnu/libc.so.6, O_RDONLY) = 3open(/lib/x86_64-linux-gnu/libdl.so.2, O_RDONLY) = 3open(/proc/filesystems, O_RDONLY)     = 3open(/etc/pam.d/chpasswd, O_RDONLY)   = 3open(/etc/pam.d/common-password, O_RDONLY) = 4open(/lib/x86_64-linux-gnu/security/pam_unix.so, O_RDONLY) = 5open(/etc/ld.so.cache, O_RDONLY)      = 5open(/lib/x86_64-linux-gnu/libnsl.so.1, O_RDONLY) = 5open(/lib/x86_64-linux-gnu/security/pam_deny.so, O_RDONLY) = 5open(/lib/x86_64-linux-gnu/security/pam_permit.so, O_RDONLY) = 5open(/etc/pam.d/other, O_RDONLY)      = 3open(/etc/pam.d/common-auth, O_RDONLY) = 4open(/etc/pam.d/common-account, O_RDONLY) = 4open(/etc/pam.d/common-password, O_RDONLY) = 4open(/etc/pam.d/common-session, O_RDONLY) = 4open(/etc/passwd, O_RDONLY)           = 3open(/etc/passwd, O_RDONLY)           = 3open(/etc/nsswitch.conf, O_RDONLY)    = 3open(/etc/ld.so.cache, O_RDONLY)      = 3open(/lib/x86_64-linux-gnu/libnss_compat.so.2, O_RDONLY) = 3open(/etc/ld.so.cache, O_RDONLY)      = 3open(/lib/x86_64-linux-gnu/libnss_nis.so.2, O_RDONLY) = 3open(/lib/x86_64-linux-gnu/libnss_files.so.2, O_RDONLY) = 3open(/etc/passwd, O_RDONLY|O_CLOEXEC) = 3open(/etc/shadow, O_RDONLY|O_CLOEXEC) = 3open(/etc/passwd, O_RDONLY|O_CLOEXEC) = 3open(/etc/shadow, O_RDONLY|O_CLOEXEC) = 3open(/etc/passwd, O_RDONLY)           = 3open(/etc/passwd, O_RDONLY)           = 3open(/etc/.pwd.lock, O_WRONLY|O_CREAT|O_CLOEXEC, 0600) = 3open(/etc/passwd, O_RDONLY|O_CLOEXEC) = 4open(/etc/shadow, O_RDONLY|O_CLOEXEC) = 4open(/dev/urandom, O_RDONLY)          = 4open(/etc/passwd, O_RDONLY|O_CLOEXEC) = 4open(/etc/passwd, O_RDONLY)           = 4open(/etc/nshadow, O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4open(/etc/shadow, O_RDONLY)           = 5open(/etc/localtime, O_RDONLY)        = 4Process 7760 attachedProcess 7759 suspendedProcess 7759 resumedProcess 7760 detached--- SIGCHLD (Child exited) @ 0 (0) ---EDIT4Eventually I've run the same command on the same container on Debian Jessie and it worked.The case is solved - Wheezy and Archlinux simply has different implementations of chpasswd.I think the best portable workaround for this problem is as suggested by @Peter Cordes:echo 'root:toor' | chroot /home/containers/wheezy/ /usr/sbin/chpasswd
chpasswd apply changes in the chroot directory
debian;arch linux;chroot;debootstrap