Cannot run programs via ssh - SSH

This is a discussion on Cannot run programs via ssh - SSH ; Hi, the authentication between my Linux machines is done by public keys without password. When I login on a machine and invoke "xterm", the application is started without any problems. However, when I run "ssh HOSTNAME xterm" I get the ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Cannot run programs via ssh

  1. Cannot run programs via ssh

    Hi,

    the authentication between my Linux machines is done
    by public keys without password.

    When I login on a machine and invoke "xterm", the
    application is started without any problems. However,
    when I run "ssh HOSTNAME xterm" I get the error message:

    stty: standard input: Invalid argument
    bash: line 1: xterm: command not found

    and xterm is not started.

    Here is my sshd_config:

    Port 22
    Protocol 2
    HostKey /etc/ssh/ssh_host_key
    HostKey /etc/ssh/ssh_host_rsa_key
    HostKey /etc/ssh/ssh_host_dsa_key
    PidFile /etc/sshd.pid
    StrictModes yes
    KeepAlive yes
    LoginGraceTime 30
    AllowTcpForwarding yes
    X11Forwarding yes
    X11DisplayOffset 10
    X11UseLocalhost yes
    ServerKeyBits 768
    KeyRegenerationInterval 3600
    PasswordAuthentication yes
    RSAAuthentication yes
    DSAAuthentication no
    RhostsRSAAuthentication yes
    HostbasedAuthentication yes
    IgnoreRhosts yes
    IgnoreUserKnownHosts yes
    PermitRootLogin yes
    PermitEmptyPasswords no
    UseLogin no
    PrintMotd no
    Compression yes
    SyslogFacility AUTH
    LogLevel INFO

    Any ideas how I can fix this problem?

    It seems that the environment variable PATH is not
    initialized correctly.

    Regards,
    Chris


  2. Re: Cannot run programs via ssh

    Christian Christmann writes:

    > Any ideas how I can fix this problem?


    Try to specify the full path to xterm and see if the problem doesn't
    go away.

    $ ssh hostname /path/to/xterm

    But first try it with a non-X program to rule out X environment issues
    in the equation.


    --
    Todd H.
    http://www.toddh.net/

  3. Re: Cannot run programs via ssh

    On Mon, 09 Oct 2006 10:41:52 -0500, Todd H. wrote:

    > Christian Christmann writes:
    >
    >> Any ideas how I can fix this problem?

    >
    > Try to specify the full path to xterm and see if the problem doesn't
    > go away.
    >
    > $ ssh hostname /path/to/xterm
    >
    > But first try it with a non-X program to rule out X environment issues
    > in the equation.


    When I specify the full path name, it works.
    non-X programs also work without the full path name.

    I think that the problem comes from the PATH variable. On my Debian
    system xterm is in /usr/X11R6/bin, but this path seems not to be
    contained in the PATH environment variable. Thus, xterm is not found.

    Are there any ways to define a PATH variable for ssh when executing
    applications (without login)? I've read somewhere that these paths
    must be specified when compiling ssh, but I don't think that this
    is the only solution.

    I also wonder why ssh does not read my /etc/profile and my
    /etc/bash.bashrc when executing an application. A possible solution
    would be to force ssh to read /etc/profiles but I couldn't find a
    way to do so. And ideas?


  4. Re: Cannot run programs via ssh

    Christian Christmann writes:

    > I also wonder why ssh does not read my /etc/profile and my
    > /etc/bash.bashrc when executing an application. A possible solution
    > would be to force ssh to read /etc/profiles but I couldn't find a
    > way to do so. And ideas?


    ssh(1)
    ...
    If command is specified, command is executed on the remote host
    instead of a login shell.

    The processing of bashrc and I believ /etc/profile are all specific
    to a login shell.

    You could always cheat and do

    ssh hostname "source /etc/profile;xterm"

    maybe?


    --
    Todd H.
    http://www.toddh.net/

  5. Re: Cannot run programs via ssh

    On Mon, 09 Oct 2006 11:51:12 -0500, Todd H. wrote:


    >
    > The processing of bashrc and I believ /etc/profile are all specific
    > to a login shell.
    >
    > You could always cheat and do
    >
    > ssh hostname "source /etc/profile;xterm"
    >
    > maybe?


    I've found that you can specify a file called sshrc in your global
    ssh directory. In that file I added an "echo" and "source /etc/profile".
    The echo is displayed when I login via ssh on that ssh server, but
    the "export PATH=$PATH:/usr/X11R6/bin" from /etc/profile is still not set.
    Why?


  6. Re: Cannot run programs via ssh

    Christian Christmann writes:
    >When I specify the full path name, it works.
    >non-X programs also work without the full path name.


    >I think that the problem comes from the PATH variable. On my Debian
    >system xterm is in /usr/X11R6/bin, but this path seems not to be
    >contained in the PATH environment variable. Thus, xterm is not found.

    ...
    >I also wonder why ssh does not read my /etc/profile and my
    >/etc/bash.bashrc when executing an application. A possible solution
    >would be to force ssh to read /etc/profiles but I couldn't find a
    >way to do so. And ideas?


    ssh running a command is an interactive shell, not a login shell. The
    man page for bash documents what rc files are sourced and in what
    order when run interactivly vs. a login shell.

    What file is /etc/bash.bashrc though? Some custom weird-random thing for
    your system? Stock bash wouldn't touch that file.

    Most likely, all you need to do is set your PATH appropriately in your
    ~/.bash_profile RC file, and you'll be all set to do whatever you want.



  7. Re: Cannot run programs via ssh

    On Mon, 09 Oct 2006 19:41:31 +0000, Doug McIntyre wrote:

    >
    > What file is /etc/bash.bashrc though? Some custom weird-random thing for
    > your system? Stock bash wouldn't touch that file.


    bash.bashrc is Debian's "systemwide per-interactive-shell startup file".

    >
    > Most likely, all you need to do is set your PATH appropriately in your
    > ~/.bash_profile RC file, and you'll be all set to do whatever you want.


    Yea, I know. Setting path in ~/.bashrc would fix my problem. However,
    I'm looking for a solution that sets the PATH variable globally
    independently of the user local settings.



+ Reply to Thread