How can I avoid running .bashrc? - SSH

This is a discussion on How can I avoid running .bashrc? - SSH ; How can I avoid running .bashrc when I specify a command to be executed *AND* use the -t option because the command needs tty semantics? What I'd really prefer is to directly execute the command WITHOUT running it through the ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: How can I avoid running .bashrc?

  1. How can I avoid running .bashrc?

    How can I avoid running .bashrc when I specify a command to be executed
    *AND* use the -t option because the command needs tty semantics?

    What I'd really prefer is to directly execute the command WITHOUT running
    it through the shell at all. I know that would mean either something else
    has to parse the command string into tokens, or the command has to be
    provided already broken into tokens. But I guess that means extending
    the SSH protocol so it can transfer the command as separated tokens instead
    of a single string.

    But for some reason, using -t triggers running the shell in interactive
    mode as opposed to command mode. Is ssh/sshd doing that or is the shell
    detecting this and making an assumption?

    If there was at least some environment variable set going into the shell
    that would indicate a command is being provided on the command line, then
    I could at least code the .bashrc to skip everything if that environment
    variable is set. But I did some tests and see nothing distinctive between
    these cases.

    --
    |---------------------------------------/----------------------------------|
    | Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
    | first name lower case at ipal.net / spamtrap-2008-03-08-2016@ipal.net |
    |------------------------------------/-------------------------------------|

  2. Re: How can I avoid running .bashrc?

    phil-news-nospam@ipal.net writes:

    >How can I avoid running .bashrc when I specify a command to be executed
    >*AND* use the -t option because the command needs tty semantics?


    Change the command so it does not require tty semantics.


    >What I'd really prefer is to directly execute the command WITHOUT running
    >it through the shell at all. I know that would mean either something else
    >has to parse the command string into tokens, or the command has to be
    >provided already broken into tokens. But I guess that means extending


    Or the command has to be written so that it does not need interpreting at
    all.

    >the SSH protocol so it can transfer the command as separated tokens instead
    >of a single string.


    >But for some reason, using -t triggers running the shell in interactive
    >mode as opposed to command mode. Is ssh/sshd doing that or is the shell
    >detecting this and making an assumption?


    >If there was at least some environment variable set going into the shell
    >that would indicate a command is being provided on the command line, then
    >I could at least code the .bashrc to skip everything if that environment
    >variable is set. But I did some tests and see nothing distinctive between
    >these cases.


    >--
    >|---------------------------------------/----------------------------------|
    >| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
    >| first name lower case at ipal.net / spamtrap-2008-03-08-2016@ipal.net |
    >|------------------------------------/-------------------------------------|


  3. Re: How can I avoid running .bashrc?

    phil-news-nospam@ipal.net schrieb:
    > How can I avoid running .bashrc when I specify a command to be executed
    > *AND* use the -t option because the command needs tty semantics?


    in the book "Adv. Programming in the Unix environment" second edition,
    on page 694 a program pty is described (source code), with can be used
    to connect a programm to a pty, i.e. fake a terminal to the command.
    The chapter clearifys a lot of pty/tty miracles to me.

    Maybe the same can be achieved by use of expect or tee, or just using
    pipes for in/output, depends on the command. E.g. if it is passwd on
    Solaris, it expect to have a stderr for the prompt "password:". Linux
    seems to can use passwd without pty/tty.


    > If there was at least some environment variable set going into the shell
    > that would indicate a command is being provided on the command line, then
    > I could at least code the .bashrc to skip everything if that environment
    > variable is set. But I did some tests and see nothing distinctive between
    > these cases.


    putty has an option for setting the terminal type, so there must be a
    protocol specification for transfer the terminal (i thing telnet has
    something to do that) and i wonder if putty does that manually. So save
    the TERM, setting it to something special, which depends on your
    programm and if it use termcap/termlib (in that case you must use a real
    term definition, but you can import your own name and minimal termcap).

    SSH 2 has the possibility to pass env, see the configuration parameters
    in openssh:
    SendEnv (ssh_config)
    AcceptEnv (sshd_config)
    also it must not be disallowed in the authorized_keys file.

    Wolfgang


+ Reply to Thread