• Re: scp in crontab problem

    From basti@21:1/5 to Marcus Park on Fri Sep 13 14:50:01 2024
    On 13.09.24 14:24, Marcus Park wrote:
    Hi list,

    I have put the private key into my debian VPS (in ~/.ssh/ dir).

    When I scp a file from this VPS to another one by hand without password,
    it works.

    But when I put this scp into crontab, it seems not work. The scp in
    crontab via private key didn't run as I expect, nothing was copied to peer.

    Can you help?

    Thank you.
    Marcus


    Cron doesn't know anything about your environment variables.
    You can set PATH or HOME or use absolute paths.

    /usr/bin/scp -i /home/userYX/.ssh/myKEY root@example.com ...

    Best regards,

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcus Park@21:1/5 to All on Fri Sep 13 14:40:02 2024
    Hi list,

    I have put the private key into my debian VPS (in ~/.ssh/ dir).

    When I scp a file from this VPS to another one by hand without password,
    it works.

    But when I put this scp into crontab, it seems not work. The scp in
    crontab via private key didn't run as I expect, nothing was copied to peer.

    Can you help?

    Thank you.
    Marcus

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to Marcus Park on Fri Sep 13 15:00:01 2024
    On Fri, Sep 13, 2024 at 20:24:51 +0800, Marcus Park wrote:
    I have put the private key into my debian VPS (in ~/.ssh/ dir).

    Does this private key have a passphrase?

    When I scp a file from this VPS to another one by hand without password, it works.

    But when I put this scp into crontab, it seems not work. The scp in crontab via private key didn't run as I expect, nothing was copied to peer.

    First question: what did the output say? Any output from the cron job
    should have been mailed to you. If you don't have a mail reader set up
    on this machine, try "less /var/mail/$LOGNAME" or something. If you
    don't have local mail delivery set up, fix that.

    Second question: if the key has a passphrase, are you using an ssh-agent
    to invoke it normally? The cron job won't have access to your ssh-agent,
    not without a bunch of additional setup.

    For automated jobs, you usually need the private key to NOT have a
    passphrase. And yes, this is a large security concern. You'll have
    to balance your security needs against your application needs.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Charles Curley@21:1/5 to Marcus Park on Fri Sep 13 15:20:01 2024
    On Fri, 13 Sep 2024 20:24:51 +0800
    Marcus Park <marp@privatembox.com> wrote:

    Hi list,

    I have put the private key into my debian VPS (in ~/.ssh/ dir).

    The private key of what?

    And to ~/.ssh/ on which computer. you are talking about transferring a
    file from one computer to another; which one?

    And why the private key? Usually one transfers the public key from
    one's own computer to another, and one keeps the private key, well,
    private.


    When I scp a file from this VPS to another one by hand without
    password, it works.

    But when I put this scp into crontab, it seems not work. The scp in
    crontab via private key didn't run as I expect, nothing was copied to
    peer.

    Don't tell us what you did, show us. Copy exactly the line(s) from your
    crontab file and paste it into your email.

    Did you get an email from cron? If so, show us that.


    Can you help?

    Not without better information.

    --
    Does anybody read signatures any more?

    https://charlescurley.com
    https://charlescurley.com/blog/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcus Park@21:1/5 to All on Sat Sep 14 00:30:01 2024
    basti:
    /usr/bin/scp -i /home/userYX/.ssh/myKEY root@example.com ...


    updated: it's really due to environment issue, after I add the '-i' path
    to scp, jobs run well now.

    Thanks basti.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)