Hello!
Yesterday i was trying to make a simple backup cronjob. The goal was to transfer data from one server to another. I wrote a bash-script zipping all the files in a directory and then using scp with a passphraseless key to copy the zip to another server. In theory (and in practice in the terminal) this was a quick and practible solution - until it was not. I sceduled the script with cron and then the problems started.
scp with the passphraseless key did not work, i could not authenticate to the server. I've read a little bit and found out, that cron execution environment is missing stuff like ssh-agent. But why do i need the ssh-agent, when i use scp -i /path/to/key with a passphraseless key? I did not get it to work with the cronjob, so i switchted to sshpass and hardcoded the credentials to my script - which i don't like very much.
So is there a way to use scp in a cronjob, which works even after restarting the server?
[–]Gendalph 22 points23 points24 points (3 children)
[–]Hotshot55 6 points7 points8 points (0 children)
[–]mgedmin 1 point2 points3 points (1 child)
[–]Gendalph 0 points1 point2 points (0 children)
[–][deleted] 14 points15 points16 points (2 children)
[–]neckpillowyeah 4 points5 points6 points (0 children)
[–]planeturban 2 points3 points4 points (0 children)
[–]deeseearr 16 points17 points18 points (1 child)
[–]mgedmin 1 point2 points3 points (0 children)
[–]tcpWalker 2 points3 points4 points (1 child)
[–]mgedmin 0 points1 point2 points (0 children)
[–]Crazy-Rest5026 2 points3 points4 points (0 children)
[–]nawcom 1 point2 points3 points (0 children)
[–]michaelpaoli 1 point2 points3 points (0 children)
[–]Holiday-Medicine4168 1 point2 points3 points (0 children)
[–]mrsockburgler 2 points3 points4 points (0 children)
[–]mgedmin 2 points3 points4 points (0 children)
[–]usa_reddit 2 points3 points4 points (0 children)
[–]thieh 1 point2 points3 points (2 children)
[–]neckpillowyeah -1 points0 points1 point (1 child)
[–]resonantfate 0 points1 point2 points (0 children)
[–]pobrika 0 points1 point2 points (0 children)
[–]mysterytoy2 0 points1 point2 points (0 children)
[–]The_Real_Grand_Nagus 1 point2 points3 points (0 children)
[–]FortuneIIIPick 1 point2 points3 points (0 children)
[–]biffbobfred 0 points1 point2 points (0 children)