庆典:检查,如果我能SSH(带键)的主机列表 [英] bash: check if I can ssh (with keys) to a list of hosts
问题描述
我想,如果我可以的 SSH 以主机的名单只用键查看
I want to check if I can ssh to a list of hosts by only using keys.
<一个href=\"http://stackoverflow.com/questions/5768130/bash-ssh-test-for-public-key-authentication\">This答案 建议执行以下操作:
This answer suggests doing the following:
exec ssh -o BatchMode=yes "user@host" true
...这应该连接到主机上,运行真正
并返回其退出状态。
在我的Ubuntu的机器就不能正常工作。东西在上面的命令强制终端关闭。我做了什么错了?
On my Ubuntu machine it doesn't work. Something in the above command forces the terminal to close. What did I do wrong?
(另外,因为我需要使用 -l </ code>选项来传递我的用户名,在常规命令是:
的ssh -l用户主机
。请问 EXEC
间preT这是别的东西吗?)
(Also, since I am required to use the -l
option to pass my username, the regular command would be: ssh -l user host
. Will exec
interpret this as something else?)
推荐答案
EXEC
使当前外壳改为 SSH
。当 SSH
退出,你的终端其实也是如此。只需使用
exec
causes the current shell to be replaced by ssh
. When ssh
exits, your terminal does as well. Just use
ssh -o BatchMode=yes "user@host" true
要回到你的后壳 SSH
完成。
这篇关于庆典:检查,如果我能SSH(带键)的主机列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!