zop*_*eux 4 ssh passphrase ssh-agent
我正在编写一个脚本来循环浏览已知主机名的列表,以便找到一个可以使用我的 SSH 密钥进行身份验证的工作 SSH 服务器。
密钥已经加载了ssh-agent
and ssh-add
,因此如果我连接到知道我的密钥的工作远程主机,则不会提示密码,并且我无需任何交互即可成功连接。
事情是,当远程主机不知道我的密钥时,ssh
会用密码提示我(它没有机会成功,因为如果可以的话,由于 ,它已经让我登录了ssh-agent
)。我想防止这种行为并ssh
在ssh-agent
身份验证失败时中止。
我目前正在使用以下命令绕过大部分交互,但我无法阻止我刚刚描述的交互:
$ ssh -i ~/.ssh/id_rsa \
-o UserKnownHostsFile=/dev/null \
-o KbdInteractiveAuthentication=no \
-o StrictHostKeyChecking=no \
-o PreferredAuthentications=publickey \
-o ConnectTimeout=1 \
$host -n "whoami"
Run Code Online (Sandbox Code Playgroud)
感谢您的回答。
人 ssh_config:
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''.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
348 次 |
最近记录: |