Ssh 阻止rsync尝试请求密码
如何防止Ssh 阻止rsync尝试请求密码,ssh,rsync,Ssh,Rsync,如何防止rsync尝试为远程服务器登录请求密码 注意:我不是问如何设置经过公钥验证的SSH。我知道如何设置经过身份验证的公钥SSH。我要问的是,如果公钥身份验证失败,如何防止rsync尝试请求密码,就像scp的-B标志所做的那样。我在这里的脚本中使用了rsync,因此如果它试图请求密码,我的脚本将挂起,等待永远不会出现的输入。我想让rsync命令失败,这样我的脚本就可以检测到失败并优雅地退出。只需将选项传递给rsync使用的底层ssh命令: rsync -e 'ssh -oBatchMode=y
rsync
尝试为远程服务器登录请求密码
注意:我不是问如何设置经过公钥验证的SSH。我知道如何设置经过身份验证的公钥SSH。我要问的是,如果公钥身份验证失败,如何防止
rsync
尝试请求密码,就像scp
的-B
标志所做的那样。我在这里的脚本中使用了rsync
,因此如果它试图请求密码,我的脚本将挂起,等待永远不会出现的输入。我想让rsync
命令失败,这样我的脚本就可以检测到失败并优雅地退出。只需将选项传递给rsync
使用的底层ssh
命令:
rsync -e 'ssh -oBatchMode=yes [other ssh options]' [rest of rsync command]
从rsync
手册:
从ssh
手册:
这模拟了bahavior osscp-B
-e, --rsh=COMMAND specify the remote shell to use
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”.