I have a question that appears very similar to others that have been asked but none of them have answered my problem. I'm running into an ssh error on sending a command (not loading an interactive shell).

The Scenario

My default shell at my company is csh instead of something more sane like bash. I know bash is supported since some other teammates use it as the default shell. For all of our processes, csh works fine but I would just like to use something better. I've modified my .cshrc to start up bash.

setenv SHELL /bin/bash
exec /bin/bash --login

That creates the shell just fine, sets the SHELL environment variable and starts bash on startup. The issue arises with all of the ssh (and rsh) commands that are run either through scripts or manually. I can run ssh user@host and get a shell just fine but I'm trying to run ssh -vvv user@host "echo hello"

It hangs at the end, after authenticating and sending the command, with

debug1: Sending command: echo hello
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0

What I've Tried

These changes are being tested by just sshing to the localhost to keep it simple.

.bashrc and .bash_profile changes

I've played around with so many different configurations of .bashrc and .bash_profile making sure it's not related to environment variables. That doesn't really seem to be the issue since they're all the same in bash as they are in csh (which works just fine).

Adding -t

I added the -t flag to ssh to connect but that doesn't actually run the command I tell it to run but gives me a shell to use. It also isn't necessarily a solution in and of itself since a bunch of scripts can't be modified as they're shared by everyone.

[user@host: ~/test ] $ ssh -t user@host "echo hello"
[user@host ~]$

Sanity Testing In csh

With -t:

[user@host: ~/test ] $ ssh -t user@host "echo hello"
Connection to host closed.
[user@host: ~/test ] $

Without -t:

[user@host: ~/test ] $ ssh -t user@host "echo hello"
[user@host: ~/test ] $

Additional Info

IT support at my company has taken a look and just said it was a problem with my bash profile and to look at my .bashrc and .bash_profile, basically telling me to figure it out myself. I'm not saying they're wrong but I am saying I've done all the debugging I can think of, which is why I'm coming here. This also pretty much means I can't change anything on the server side and have to rely on the client/user side.

Bash is definitely loaded and not running csh with my .cshrc changes, as judged by ps:

   PID TTY          TIME CMD
  6725 pts/68   00:00:00 bash
 26391 pts/68   00:00:00 ps


What the heck is going on? I'm pretty confused since I don't know all that much about the inner workings of ssh and I'm even less certain why csh would behave one way and bash another. Is my bash startup funky?


Answering my own question but...I tried something new that seemed to work?

I ended up moving the bash startup commands (the setenv and exec) from .cshrc to .login. I have no idea why this would change things since as far as I know, csh loads both of those things the same way and one right after another. But with that, ssh now works and all my scripts I needed runs. So...if anyone else ever has an issue like this, try this simple step.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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