Results 1 to 3 of 3

Thread: sftp automation and cronjob

  1. #1
    Join Date
    May 2009
    Beans
    51
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Question sftp automation and cronjob

    Hello

    I need to upload a txt file to a server once per day on a specific time. Is the a way to use sftp and cronjob to do the task?

    10x

  2. #2
    Join Date
    Sep 2006
    Beans
    8,623
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: sftp automation and cronjob

    sftp can use keys for authentication, use the -i option. That is the best way to do it.

    You can even put the keys in an agent and use that in cron, though that takes a little planning.

    You can also make the key single purpose and lock it to using sftp by prepending the key with a forced command.

    Code:
    command="/usr/libexec/sftp-server" ssh-rsa AAAAB3NzaC1yc2EAA...
    command="/usr/lib/openssh/sftp-server" ssh-rsa AAAAB3NzaC1yc2EAA...
    Edit: Once you have keys working, you can use batch mode (-b) to do the upload.
    Last edited by Lars Noodén; November 15th, 2012 at 09:05 AM.

  3. #3
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,294
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: sftp automation and cronjob

    For a single file, scp would probably be better (but the same things apply for authentication, of course).
    「明後日の夕方には帰ってるからね。」


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •