how to do the oauth2 interactive authentication when run from cron (backup to google drive)?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to do the oauth2 interactive authentication when run from cron (backup to google drive)?

duplicity-talk mailing list
i did a test run for my backup script from the command line (as root) and did the offline access type authentication where you paste a code from the webbrowser to the commandline. That backup went fine.

now from cron the script runs as root, too, and demands the same kind of authentication again. it does not so that when running from the command line. 

how do i solve this?

kind regards,

Andreas

_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk
Reply | Threaded
Open this post in threaded view
|

Re: how to do the oauth2 interactive authentication when run from cron (backup to google drive)?

duplicity-talk mailing list
Which OS/version?  Which duplicity/version?  What is your command line?

The backend will normally save a .file in the user's home directory.  If you do "sudo duplicity ...", that will use your home dir, not root's.  To fix this, do "$ sudo -i duplicity ..." to login as root and use root's home dir.  Or, you can find the .file and copy it to /root.  You may need to chown it to root.

Hope that helps!

...Ken


On Wed, May 2, 2018 at 10:03 AM, Andreas Schuldei via Duplicity-talk <[hidden email]> wrote:
i did a test run for my backup script from the command line (as root) and did the offline access type authentication where you paste a code from the webbrowser to the commandline. That backup went fine.

now from cron the script runs as root, too, and demands the same kind of authentication again. it does not so that when running from the command line. 

how do i solve this?

kind regards,

Andreas

_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk



_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk
Reply | Threaded
Open this post in threaded view
|

Re: how to do the oauth2 interactive authentication when run from cron (backup to google drive)?

duplicity-talk mailing list
actually i do get the error before my traceback: 
/usr/local/lib/python2.7/dist-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access <filename to cache credentials>: No such file or directory

could it be that this is just a very unfortunate choice of filename and the > and < are interpreted? (I am aware the shell should not be involved at this point, but those are still special chars, even vor python.)  The $HOME and user (that the process runs as, root) are all correct.

On Thu, May 3, 2018 at 9:41 AM Andreas Schuldei <[hidden email]> wrote:
apt-cache policy duplicity 
duplicity:
  Installed: 0.7.17-0ubuntu0ppa1353~ubuntu18.04.1
  Candidate: 0.7.17-0ubuntu0ppa1353~ubuntu18.04.1
  Version table:
 *** 0.7.17-0ubuntu0ppa1353~ubuntu18.04.1 100
        100 /var/lib/dpkg/status
     0.7.11-1 500
        500 http://ftp.debian.org/debian stretch/main armel Packages

i build that package from source, using (and slightly adjusting) the ubuntu package, so it builds on debian.

cat /etc/debian_version 
9.0


you say it creates a .file in $HOME. actually there is a file with the funny name "<filename to cache credentials>" ("<" and ">" as part of the filename. there is no ".file", though. the backup runs as user root, though. I added further debugging and copied the funny file (which does contain google authentication credentials) to ".file". lets see if that works tomorrow night when the backup is supposed to run.


On Wed, May 2, 2018 at 9:47 PM Kenneth Loafman <[hidden email]> wrote:
Which OS/version?  Which duplicity/version?  What is your command line?

The backend will normally save a .file in the user's home directory.  If you do "sudo duplicity ...", that will use your home dir, not root's.  To fix this, do "$ sudo -i duplicity ..." to login as root and use root's home dir.  Or, you can find the .file and copy it to /root.  You may need to chown it to root.

Hope that helps!

...Ken


On Wed, May 2, 2018 at 10:03 AM, Andreas Schuldei via Duplicity-talk <[hidden email]> wrote:
i did a test run for my backup script from the command line (as root) and did the offline access type authentication where you paste a code from the webbrowser to the commandline. That backup went fine.

now from cron the script runs as root, too, and demands the same kind of authentication again. it does not so that when running from the command line. 

how do i solve this?

kind regards,

Andreas

_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk



_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk
Reply | Threaded
Open this post in threaded view
|

Re: how to do the oauth2 interactive authentication when run from cron (backup to google drive)?

duplicity-talk mailing list
When I said ".file", I should have said "dot file" as a generic reference.  The "<filename to cache credentials>" needs to be in the $HOME directory of whatever user is active.  You could copy the file, or sudo to root (with -i) and re-auth.

Yes, even though it's a strictly legal filename, it would be a PITA to use from a shell.


On Fri, May 4, 2018 at 2:19 AM, Andreas Schuldei <[hidden email]> wrote:
actually i do get the error before my traceback: 
/usr/local/lib/python2.7/dist-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access <filename to cache credentials>: No such file or directory

could it be that this is just a very unfortunate choice of filename and the > and < are interpreted? (I am aware the shell should not be involved at this point, but those are still special chars, even vor python.)  The $HOME and user (that the process runs as, root) are all correct.

On Thu, May 3, 2018 at 9:41 AM Andreas Schuldei <[hidden email]> wrote:
apt-cache policy duplicity 
duplicity:
  Installed: 0.7.17-0ubuntu0ppa1353~ubuntu18.04.1
  Candidate: 0.7.17-0ubuntu0ppa1353~ubuntu18.04.1
  Version table:
 *** 0.7.17-0ubuntu0ppa1353~ubuntu18.04.1 100
        100 /var/lib/dpkg/status
     0.7.11-1 500
        500 http://ftp.debian.org/debian stretch/main armel Packages

i build that package from source, using (and slightly adjusting) the ubuntu package, so it builds on debian.

cat /etc/debian_version 
9.0


you say it creates a .file in $HOME. actually there is a file with the funny name "<filename to cache credentials>" ("<" and ">" as part of the filename. there is no ".file", though. the backup runs as user root, though. I added further debugging and copied the funny file (which does contain google authentication credentials) to ".file". lets see if that works tomorrow night when the backup is supposed to run.


On Wed, May 2, 2018 at 9:47 PM Kenneth Loafman <[hidden email]> wrote:
Which OS/version?  Which duplicity/version?  What is your command line?

The backend will normally save a .file in the user's home directory.  If you do "sudo duplicity ...", that will use your home dir, not root's.  To fix this, do "$ sudo -i duplicity ..." to login as root and use root's home dir.  Or, you can find the .file and copy it to /root.  You may need to chown it to root.

Hope that helps!

...Ken


On Wed, May 2, 2018 at 10:03 AM, Andreas Schuldei via Duplicity-talk <[hidden email]> wrote:
i did a test run for my backup script from the command line (as root) and did the offline access type authentication where you paste a code from the webbrowser to the commandline. That backup went fine.

now from cron the script runs as root, too, and demands the same kind of authentication again. it does not so that when running from the command line. 

how do i solve this?

kind regards,

Andreas

_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk




_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk