Linux – Can a user be excluded from /etc/profile.d scripts

bashlinuxprofilersyncssh

I am having a problem using Rsync/SSH with a specific user for Amanda backups on a server.

rsync -e 'ssh -i /var/lib/amanda/.ssh/id_rsa_amdump' -az otherserver:/dir/to/copy /copy/dir

I have noticed that it gives all kinds of errors on a script within /etc/profile.d and cannot log on with the SSH key. If I try to log into the user account with SSH it just displays errors and will not give a prompt. Is there a way to tell the user to not read /etc/profile.d or to set it to skip/exclude that user?

The errors it gives on log on attempt with SSH is:

/etc/profile.d/somescript.sh line 125: bind: warning: line editing not enabled

It shows this error for at least 20 different lines inside the script. I do not get this error for any other user. In addition the home directory for the Amanda backup user is in /var/lib/ not /home.

Best Answer

Using bind only makes sense in a interactive shell. In somescript.sh check if the shell is interactive and only run bind if it is. For example,

if [ -n "$PS1" ]; then
    bind -x '"\e[M":'$'"ls -l"';
fi
Related Topic