Allow scp (and other non-interactive shell utilities)

Questions and answers about how to do stuff
Post Reply
mcspaul
Posts: 3
Joined: 24 Mar 2014 16:46

Allow scp (and other non-interactive shell utilities)

Post by mcspaul »

Last night I needed to configure the postfix relay_recipients option at one of my clients so that their Microsoft Exchange mail server would not receive any mail for non-existent users. I configured one of their servers to output the email addresses for all users to a file on a regular basis. The plan was to copy this file over to their EFA server using the pscp program. Unfortunately since the SSH server on EFA was configured to prevent root logins I needed to use another account. In order to avoid creating another separate local account on the EFA server just to transfer a file I decided it would be best to just use the normal/secondary account created by EFA. The problem was that since the EFA configure program was set to run in the bashrc file, scp kept failing. The solution was to modify the bashrc script to only run the EFA configure program for interactive shell logins. Below is the specific changes I made to prevent the EFA configure program from running if the bashrc script is called during a non-interactive login such as that used by scp.

Change the first line of code in the .bashrc file from

Code: Select all

sudo /usr/local/sbin/EFA-Configure
to

Code: Select all

if ! [ -z "$PS1" ]; then 
	sudo /usr/local/sbin/EFA-Configure
fi
Now scp and other non-interactive shell programs will work correctly yet when the user logs in directly they will still be presented with the EFA configure menu.
User avatar
Socal_Steve
Posts: 30
Joined: 20 Mar 2014 20:10
Location: Laguna Beach, California, USA
Contact:

Re: Allow scp (and other non-interactive shell utilities)

Post by Socal_Steve »

This is awesome - thanks! :clap:
Post Reply