I'm using the maven antrun plugin to execute an sshexec command in order to copy a tar and extract it to a target directory on a remote server.The command I run to extract it is:/bin/sh -c 'tar -vxzf /path/to/${artifact}.tar.gz -C path/to/target/directory;'This used to work fine until the owner of the target directory changed to a new user that is setup as nologin. I'm trying to figure out how to run this command as the new user.I've tried to model it after Basil A's answer/bin/su -s /bin/sh -c 'tar -vxzf /path/to/${artifact}.tar.gz -C path/to/target/directory;' ${newUser}But it prompts me for a password, which isn't going to work since its a nologin user.Also, I'm not an expert on Linux but if I also just try to simply run this command from my home directory as the old user (which has sudo access), this failssudo -u ${newUser} tar -vxzf /path/to/${artifact}.tar.gz -C path/to/target/directory;However, if I cd to the target directory and run that same exact command as the old user it works.  I'm guessing maybe if I understand this difference in behavior it will help me get the answer?
run command as different nologin user
linux;shell;permissions;sudo