view · edit · print · history

You may want to run a different shell when using root interactively under unslung.

The (good) advice here has always been 'don't do that, you can mess up the linksys/optware software'.

Here's a work-around that ONLY changes your shell under ssh. (You wouldn't use telnet except in dire circumstances because it's insecure.) The example here is for bash, but you can easily modify it for other shells. Replace /bin/bash with your favorite shell in the two places where it appears.

While we're on the subject of ssh - don't forget to switch PasswordAuthentication? to 'no' in sshd_config - as soon as you've registered your public keys in $HOME/.ssh/authorized_keys.


# Hackque:
#  If we're running under sshd & not already a bash shell, exec bash
#  This allows root to remain a /bin/sh shell for all linksys scripts & processes.
#  It sends interactive sessions to bash
#  'sh' will get a standard shell if desired
if [ "$SHELL" = "/bin/sh" ] && [ -z "$BASH" ] && ps $PPID | sed -n -e"/^ *$PPID.*?/p" | grep -q "sshd: $USER@ttyp" ; then
  if [ -x /bin/bash ]; then
        exec /bin/bash



Attempting to use this .profile on SlugOSLE?-4.8beta didn't seem to work as ssh now identifys itself as user@pts/0 instead of user@ttyp0, so I tweaked with it until I got a proper # prompt... Also added a notice banner that BASH was being used instead of sh.


if [ "$SHELL" = "/bin/sh" ] && [ -z "$BASH" ] && ps $PPID | sed -n -e"/^ *$PPID.*?/p" | grep -q "sshd: $USER@pts" ; then
  if [ -x /bin/bash ]; then
        echo NSLU2-SlugOS: Interactive SSH Connection detected. Using BASH over SH.
        exec /bin/bash

Good luck!

view · edit · print · history · Last edited by Kamilion.
Based on work by Kamilion.
Originally by tlhackque.
Page last modified on July 21, 2008, at 03:39 PM