jerrygarciuh
jerrygarciuh

Reputation: 21998

Can scp be used non-interactively in cron without generating keys?

I have a nightly database backup which I would like to scp to a remote server. As near as I can tell scp cannot be invoked with a password in the command and instead you need to set up keys for the servers?

Per this: http://www.spaceprogram.com/knowledge/cron_scp.html

The remote box owner does not want me to set up the keys so what would you do to get the file from one box to the other via a cron job?

Thanks.

Upvotes: 2

Views: 1414

Answers (1)

Borealid
Borealid

Reputation: 98489

Why does the remote owner not want you to set up keys?

The key is the same as a password, or even better because it's easier to track where it's used. The right solution is, without a doubt, to generate a keypair and use that for unattended authentication.

Now, if you really need to use scp without public-key auth, you can do it either by using an expect library to enter the password into scp, or by using an ssh library instead of invoking the scp command externally. Either way, you'll have to set up a wrapper that gets used by cron instead of calling scp directly.

Upvotes: 1

Related Questions