[clue-tech] Question for script wizards

jacob jborer at gmail.com
Thu Apr 9 21:28:58 MDT 2009


On Thu, Apr 9, 2009 at 9:09 PM, Sean LeBlanc <seanleblanc at comcast.net> wrote:
> On 04-09 20:34, Dennis J Perkins wrote:
>> On Thu, 2009-04-09 at 17:26 -0600, Sean LeBlanc wrote:
>> > On 04-09 22:32, dennisjperkins at comcast.net wrote:
>> > > I've never thought about it and I don't really use ssh since I have
>> > > nothing to ssh to, but wouldn't you get the login shell that is specified
>> > > for you in /etc/passwd? If so, can you change your login shell on each
>> > > remote host?
>> >
>> > I would, but it's the same user on the host. In other words, shared. I find
>> > myself typing "bash" everytime I log in. There is some other config I'd like
>> > to do to, too, but that's the first thing.
>>
>>
>> Try checking TERM.  I suspect when you are logged in locally, you are
>> using a desktop environment and a KDE or GNOME terminal program.  If so,
>> is your remote login shell different?  If yes, try this:
>>
>> if [ "$TERM" = "term" ]; then
>>     exec bash
>> fi
>
> It would be the same for all other staff using this same machine and user.
> They all come in via ssh. Only real difference is what machine they are
> starting the ssh client from.
>
> I wasn't having any luck with tty or who or whoami. Maybe there is something
> about those that I don't know, though.
>
> I think I may have found what I need to do, although I haven't done it yet.
> Apparently, ssh (usually according to man page) sets some vars. One of which
> is SSH_CONNECTION.
>
> I'll parse that, find out what the client ip is, and then, based on that, I
> can decide to invoke bash or not in one of the scripts. Probably
> .bash_profile?

I found an option to ssh you may want to look into, from the sshd man page:

   environment="NAME=value"
             Specifies that the string is to be added to the environment when
             logging in using this key.  Environment variables set this way
             override other default environment values.  Multiple options of
             this type are permitted.  Environment processing is disabled by
             default and is controlled via the PermitUserEnvironment option.
             This option is automatically disabled if UseLogin is enabled.

So set up a different key pair for each user that is going to use this
account, on the remote machine turn on PermitUserEnvironment, for each
key set the appropriate environment="VAR=shell" in the
~/.ssh.authorized_keys file, and use this new environment variable in
the default shell's startup files to determine if you need to exec the
another shell.

-jacob


More information about the clue-tech mailing list