Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following setup on my ubuntu 10.04 box

~$ echo $SHELL
~$ grep $USER /etc/passwd

However, when I run a remote command, zsh seems to be the default shell:

$> ssh -i /path/to/ssh/key ubuntu@<my-host> "echo $SHELL"

How do I fix this?

share|improve this question

What you are seeing there is the local login shell.

ssh user@host "echo $SHELL"

With the above, $SHELL is expanded before ssh is run because it's enclosed in double quotes. So on the remote end you're running echo /bin/zsh instead of echo $SHELL.

Use single quotes to avoid $SHELL being expanded locally.

ssh user@host 'echo "$SHELL"'

See BashFAQ 96 for more on this.

share|improve this answer

You or someone else must have configured your remote host with zsh. To switch back to bash use:

chsh -s /bin/bash

on your remote host.

Though as an aside I would recommend zsh it's an awesome shell with lots of very useful features, and having it enabled doesn't stop you from being able to use bash


will still run your scripts under bash.

share|improve this answer
that doesn't help :( In fact I noticed that chsh thinks that my default shell is bash already (from the 'current value' that it showed to me) – Raghuram Mar 28 '12 at 7:51
My only other suggestion would be to look at the key then. You can run forced commands from keys. – bodhi.zazen Mar 28 '12 at 12:52

read up on login vs non-login shells. my suspicion is that you're doing something funny in ~/.bash_profile, ~/.bashrc, or ~/.profile, so check their contents for something that would do this.

share|improve this answer
There is nothing that I can find suspicious in the ~/.bashrc or ~/.profile files (there is no ~/.bash_profile file). Specifically, there is no switch or reference to zsh. Is there anything else that I might be missing? If it helps, this is a ec2 instance using the public AMI: ami-349b495d – Raghuram Mar 28 '12 at 7:48

Your Answer


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.