How do I change my default shell on a remote server?

I tried changing it the way recommended in How do I change my default shell on a AWS instance?, as shown below:

chsh -s $(which zsh)

but that gave me an error. The system asks me to use ypchsh instead, but that gives me this error message:

ypchsh: can't get local yp domain: Local domain name not set

What can I do to set my remote shell to zsh?


You could contact the system administrator and ask if that is supposed to be supported, and if so for him/her to fix it.

What I do in a cluster where changing the shell to zsh is not supported is this (inside my ~/.bashrc):

# if this is an interactive shell
if [[ $- == *i* ]]; then
  # if on one of those annoying hosts...
  if [[ `uname -n` == PATTERN_MATCHING_SOME_HOSTNAMES ]]; then
     # if there is actually a zsh command available
     if [[ -x `which --skip-alias zsh 2>/dev/null` ]]; then
        # avoid spawning zsh every time bash is started...
        if [ -z $ZSH_STARTED ]; then
            export ZSH_STARTED="true"
            # if the call to zsh fails, scp a different conf there
            exec zsh
        fi
     fi
  fi
fi