awk命令检查与peerIP的SSH连接是否成功
该命令
ssh -q -o "BatchMode=yes" user@host "echo 2>&1" && echo "OK" || echo "NOK"
将帮助检查与对等 IP 的 SSH 连接是否成功。 但我只有对等 IP,所以
ssh -q -o "BatchMode=yes" peerIP 2>&1" && echo "OK" || echo "NOK"
不起作用。
有人知道我该如何解决吗?需要一个单行命令,它应该可以在 AIX、HP、Linux 上运行...非常感谢任何帮助或建议。
The command
ssh -q -o "BatchMode=yes" user@host "echo 2>&1" && echo "OK" || echo "NOK"
will help in checking whether the SSH connection to peer IP is a success or not.
But I am having only Peer IP so
ssh -q -o "BatchMode=yes" peerIP 2>&1" && echo "OK" || echo "NOK"
doesnt work.
Anyone knows how can i solve it? A One-liner command is required and it should work on AIX, HP, Linux... any help or suggestion is very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么提到 awk ?
不管怎样,这里有一个适合我的解决方案:
当 SSH 连接到主机时,将设置一些环境变量。
此外,当您在 SSH URL 中不使用用户连接到远程主机时,您的当前应该设置为默认值。您可以在 */etc/ssh/ssh_config* 中更改该行为。
也许这会解决它。
祝你好运
Why do you mention awk ?
Whatever, here a solution that works for me:
When SSH is connected to the host, some environment variable will be set.
Also, when your connection to a remote host without using a User in the SSH URL, your current should be set by default. You can change that behavior in your */etc/ssh/ssh_config* .
Maybe that will fix it.
Good luck