ssh command with cron - Aix

This is a discussion on ssh command with cron - Aix ; hi, I have a script executing a ssh command. The script works fine from command line. but doesn't from root cron. the ssh is from aix server to windows server. script called /tmp/fred vi /tmp/fred #!/bin/ksh set -x /usr/bin/ssh -v ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: ssh command with cron

  1. ssh command with cron

    hi,
    I have a script executing a ssh command.
    The script works fine from command line.
    but doesn't from root cron.

    the ssh is from aix server to windows server.

    script called /tmp/fred
    vi /tmp/fred
    #!/bin/ksh
    set -x
    /usr/bin/ssh -v -i /.ssh/id_rsa Administrateur@cassandre 'D:\oracle
    \Admin\Adexpr01\recap01\full_recap_new.bat'

    ls -l /tmp/fred
    -rwxrwxrwx 1 root system 350 Nov 19 17:31 /tmp/fred

    extract from /var/spool/cron/crontabs/root
    00 18 * * * /tmp/fred

    ls -l /usr/bin/ssh
    -r-xr-xr-x 1 root system 548021 Jul 22 2005 /usr/bin/ssh

    -i try ssh command with "-i" option

    -i try to follow solutions from identical problem found on web:
    in .profile of root user:
    eval `ssh-agent -s` >/dev/null
    ssh-add < /dev/null 2>/dev/null
    ssh-add ~/.ssh/id_rsa < /dev/null 2>/dev/null
    echo "SSH_AGENT_PID=$SSH_AGENT_PID" > ~/.ssh-agent
    echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> ~/.ssh-agent
    echo "export SSH_AGENT_PID SSH_AUTH_SOCK" >> ~/.ssh-agent

    and in /tmp/fred script:
    . ~/.ssh-agent
    before running ssh command.

    still not work.

    need some help, thanks

  2. Re: ssh command with cron

    In
    news:582465f2-f416-4a8e-a7ba-92a676a8aaea@p69g2000hsa.googlegroups.com,
    Uzytkownik typed:

    > hi,
    > I have a script executing a ssh command.
    > The script works fine from command line.
    > but doesn't from root cron.
    >
    > the ssh is from aix server to windows server.
    >
    > script called /tmp/fred
    > vi /tmp/fred
    > #!/bin/ksh
    > set -x
    > /usr/bin/ssh -v -i /.ssh/id_rsa Administrateur@cassandre 'D:\oracle
    > \Admin\Adexpr01\recap01\full_recap_new.bat'
    >
    > ls -l /tmp/fred
    > -rwxrwxrwx 1 root system 350 Nov 19 17:31 /tmp/fred
    >
    > extract from /var/spool/cron/crontabs/root
    > 00 18 * * * /tmp/fred

    [...]
    > need some help, thanks


    Why don't you try to debug it

    crontab -e
    00 18 * * * /tmp/fred 1> /tmp/ssh.debug 2>&1



    --
    Pozdrawiam
    Piotrek Kapczuk


  3. Re: ssh command with cron

    try the -b option .. redirect stdin

    HTH
    Mark Taylor


  4. Re: ssh command with cron

    In
    news:fd6c43c7-27a8-46fc-bb7c-f6bc5264950f@e4g2000hsg.googlegroups.com,
    Mark Taylor typed:

    > try the -b option .. redirect stdin


    I'm affraid I don't understand.
    How and where may I use it ?

    --
    Regards
    Piotrek Kapczuk


  5. Re: ssh command with cron

    piotr::kapczuk schrieb:
    > In
    > news:fd6c43c7-27a8-46fc-bb7c-f6bc5264950f@e4g2000hsg.googlegroups.com,
    > Mark Taylor typed:
    >
    >> try the -b option .. redirect stdin

    >
    > I'm affraid I don't understand.
    > How and where may I use it ?
    >

    ssh docu: [-b bind_address] seems to be a typo.
    'B' and 'N' are too close on a keyboard.
    -n Redirects stdin from /dev/null (actually, prevents reading from
    stdin). This must be used when ssh is run in the background. A
    common trick is to use this to run X11 programs on a remote ma-
    chine. For example, ssh -n shadows.cs.hut.fi emacs & will start
    an emacs on shadows.cs.hut.fi, and the X11 connection will be au-
    tomatically forwarded over an encrypted channel. The ssh program
    will be put in the background. (This does not work if ssh needs
    to ask for a password or passphrase; see also the -f option.)

    Try /usr/bin/ssh -n -v -i ... in your script.

  6. Re: ssh command with cron

    In news:474332c2$0$5065$ba4acef3@news.orange.fr,
    Thomas Braunbeck typed:

    > piotr::kapczuk schrieb:
    >> In
    >>

    news:fd6c43c7-27a8-46fc-bb7c-f6bc5264950f@e4g2000hsg.googlegroups.com,
    >> Mark Taylor typed:
    >>
    >>> try the -b option .. redirect stdin

    >>
    >> I'm affraid I don't understand.
    >> How and where may I use it ?
    >>

    > ssh docu: [-b bind_address] seems to be a typo.
    > 'B' and 'N' are too close on a keyboard.
    > -n Redirects stdin from /dev/null (actually, prevents reading from
    > stdin). This must be used when ssh is run in the background. A
    > common trick is to use this to run X11 programs on a remote ma-
    > chine. For example, ssh -n shadows.cs.hut.fi emacs & will start
    > an emacs on shadows.cs.hut.fi, and the X11 connection will be au-
    > tomatically forwarded over an encrypted channel. The ssh program
    > will be put in the background. (This does not work if ssh needs
    > to ask for a password or passphrase; see also the -f option.)


    OK. I see now. Thanks.

    > Try /usr/bin/ssh -n -v -i ... in your script.


    Actually Frederic should

    --
    Regards
    Piotrek Kapczuk


  7. Re: ssh command with cron

    sorry, yes, typo ... ssh -n or ssh somehost some_command
    Rgds
    Mark Taylor


  8. Re: ssh command with cron

    I found where was the problem.
    i use freeSSHD V1.0.10 for the ssh server on windows.
    I upgrade to V1.2.0 and now, it work from cron.

    thank you all.

+ Reply to Thread