Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have the following setup on my ubuntu 10.04 box

~$ echo $SHELL
/bin/bash
~$ grep $USER /etc/passwd
ubuntu:x:1000:1000:Ubuntu,,,:/home/ubuntu:/bin/bash

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"
/bin/zsh

How do I fix this?

share|improve this question

3 Answers 3

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

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

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

#!/bin/sh 

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

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.