Batch FTP/SFTP scripts in UNIX/BSD

Superwormy

Golden Member
Feb 7, 2001
1,637
0
0
I need to have a cronjob for our BSD server that backs up some files.

Basically what I want it to do is copy some folders, tar everything up, then FTP it to our offsite backup machine. The copying and tarring works fine, so now I just need it to FTP.

I can connect to the remote machine, but how can I have the shell script login non-interactivly ( ie make the shell script login on its own, so that it doesn't prompt for username/password and all )

The only information I can' find on this involves something with trading public SSH keys or something... not sure I entirely understand that, but if anyone would walk me through either making a shell script that logs in to an SFTP server and does something, or how to set up the SSH keys so that the user doesn't need to provide a password but is still secure and logged in...

I'd much appreciate any help! Thanks!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I was doing something similar at work and while it's definatly possible and not that hard (not that I remember the specifics right now) I found it frustrating to write a decent script because the CLI ftp on the host I was writing it for returned 0 no matter what happened so there was no way to do error checking to see if the transfer completed. I gave up and rewrote the script in perl using Net:FTP.

You could also use the scp or sftp method if you have an SSH server handy, doing public key authentication isn't terribly hard and is probably a better idea than storing a username/password in a file somewhere on the system.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
For FTP: .netrc

But it's horribly insecure.

IBM had a nice document on setting up SSH keys a few years ago. It shouldn't be tough to get it setup. Turn off passwords, make a key, and set it up to use that key.
 

uOpt

Golden Member
Oct 19, 2004
1,628
0
0
ssh keys without password. if the eys are not accessible outside the cron job it is even reasonably secure.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |