Linux shell 脚本 rsync 密码文件选项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4277549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 00:08:03  来源:igfitidea点击:

shell script rsync password file option

linuxshellbackuprsync

提问by Rajeev

In a shell script how to use rsync --password-fileoption

在shell脚本中如何使用rsync --password-file选项

rsync -a [email protected]:/root /backup

回答by citrin

If protocol is rsync you can use:

如果协议是 rsync 你可以使用:

rsync -a --password-file=/path/to/secret rsync://[email protected]/root /backup

If rsync over ssh used, you should setup public key ssh auth. On local host run

如果使用 ssh 上的 rsync,您应该设置公钥 ssh 身份验证。在本地主机上运行

ssh-keygen -t rsa -b 1024

then add content of ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys on remote host.

然后将 ~/.ssh/id_rsa.pub 的内容添加到远程主机上的 ~/.ssh/authorized_keys 。