0

As I am running this script as a Cron Job, I need to enter username and password every time when I try to SFTP to host. Below is the sample script I made which demands some modifications

#!/bin/sh

sftp -i /path/to/private/key/ username@123.123.123.123 <<EOF
put /home/sample.txt /home/
exit
EOF

Instead of private key path, I believe we insert password path. Although this is human intervention. I need it to be automated.

How can I resolve the issue ?

Tanay Suthar
  • 453
  • 3
  • 8
  • 19
  • 2
    What's the problem with the private key approach? – Leon Feb 28 '17 at 09:13
  • @Leon: There is nothing wrong in it. I can use it. But the main question lies here is, how do I automate as I am using cron Job ? – Tanay Suthar Feb 28 '17 at 09:19
  • 1
    If you can use a private key, just use the script you have. What do you want to "automate" about that? It's automatic already! – Martin Prikryl Feb 28 '17 at 09:22
  • @MartinPrikryl: That's correct. If I am using a password based authentication for sftp then what would be the possible syntax, will it be like sftp -p /path/to/password/ username@123.123.123.123 ? – Tanay Suthar Feb 28 '17 at 09:33

0 Answers0