Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

A user account has it's shell defined in passwd file as bash. I would like to change this user account's shell to tcsh for non-interactive jobs (like ssh ), but keep interactive shell to bash. Is there any way to configure this on the system?

share|improve this question
    
You can use "ForceCommand" option in config of sshd with specified full path to new shell. However it will not restrict user from access of initial shell. Could you please elaborate what do you mean by non-interactive? –  Navern Aug 27 '14 at 15:29
1  
If you intend to use tcsh for some remote scripts called by ssh, you merely can invoke tcsh in you ssh command line. –  tonioc Aug 28 '14 at 7:38

1 Answer 1

If you want login shells to use one shell, but non-login shells to use another, you can achieve this by defining the default shell for the user (in /etc/passwd) as the one that is to be used as the non-login shell (tcsh in your case), then switching to a different shell when a login shell is opened.

In your case this can be acomplished by adding this to the file named ".profile" in the users home-directory (creating it if it doesn't exist yet):

# Switch to bash for login shells
if [ ! -n "$BASH_VERSION" ]
then
        exec /bin/bash -l
fi
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.