gpt4 book ai didi

ssh - 防止 rsync 尝试询问密码

转载 作者:行者123 更新时间:2023-12-02 13:51:12 27 4
gpt4 key购买 nike

如何预防 rsync从试图询问远程服务器登录密码?

注意:我不是在问如何设置公钥认证的 SSH。我知道如何设置公钥认证的 SSH。我要问的是如何预防rsync如果公钥身份验证失败,则尝试询问密码,例如 scp-B标志可以。我正在使用 rsync在这里的脚本中,所以如果它试图询问密码,我的脚本将挂起,等待永远不会出现的输入。我想要 rsync命令改为失败,因此我的脚本可以检测到失败并正常退出。

最佳答案

只需将选项传递给底层 ssh rsync 使用的命令:

rsync -e 'ssh -oBatchMode=yes [other ssh options]' [rest of rsync command]

来自 rsync手动的:

-e, --rsh=COMMAND           specify the remote shell to use


来自 ssh手动的:

BatchMode

If set to “yes”, passphrase/password querying will be disabled.
This option is useful in scripts and other batch jobs where no
user is present to supply the password. The argument must be
“yes” or “no”. The default is “no”.


这模拟了行为操作系统 scp -B .

关于ssh - 防止 rsync 尝试询问密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37840507/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com