scp 可以在 cron 中以非交互方式使用而不生成密钥吗?
我有一个夜间数据库备份,我想将其 scp 到远程服务器。据我所知,无法在命令中使用密码调用 scp,而是需要为服务器设置密钥?
据此:http://www.spaceprogram.com/knowledge/cron_scp.html
远程盒子所有者不希望我设置密钥,那么你会如何通过 cron 作业将文件从一个盒子获取到另一个盒子?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么远程所有者不希望您设置密钥?
密钥与密码相同,甚至更好,因为更容易追踪其使用地点。毫无疑问,正确的解决方案是生成密钥对并将其用于无人值守身份验证。
现在,如果您确实需要在没有公钥身份验证的情况下使用
scp
,您可以通过使用expect
库将密码输入scp,或使用
ssh
库而不是从外部调用scp
命令。无论哪种方式,您都必须设置一个由cron
使用的包装器,而不是直接调用scp
。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 anexpect
library to enter the password intoscp
, or by using anssh
library instead of invoking thescp
command externally. Either way, you'll have to set up a wrapper that gets used bycron
instead of callingscp
directly.