linux - 如何在 bash 脚本中获取控制台输入以使用 SSL?

标签 linux bash ssl websphere-liberty

对于我正在使用的服务器技术,可以通过运行一些命令行参数来手动将服务器加入到集合中。在某一时刻,控制台会提示您是否要接受证书链,您输入(y/n),命令就会继续运行。我正在尝试使该过程自动化,但在响应输入提示时遇到了障碍,并且在深入研究后听说这可能是 SSL 的事情,所以我不知道是否有不同的方法来做到这一点。

如果您手动执行此操作,则结果如下:

Joining the collective with target controller ...this may take a while
SSL trust has not been established with the target server
//certificate chain
Do you want to accept the above certificate chain? (y/n)

但是,两者:

echo "y y" | bash ./script.sh

//inside script.sh
echo "y y" | $(command)

最终得到以下回复:

Joining the collective with target controller ...this may take a while
SSL trust has not been established with the target server
//certificate chain

Input console is not available 

Aborting join collective.

Error:
Unable to complete the MBean operation
Error: java.securit.cert.CertificateException: User has rejected the request to trust the
certificate chain

我希望有人能够阐明一种除了手动响应之外的方法

最佳答案

错误Input console is not available表明目标程序期望与真实的终端通信,而不是管道(这是如果您尝试 echo 进入程序时得到的结果)。

在这种情况下,您将使用类似 expect 的内容来自动化程序。 ,它模拟真实的终端(使用伪终端),并且通常可以“欺骗”这样的程序,使其相信它们正在与真实的终端进行通信。 expect可以让你在程序中输入任意命令。

参见Bash/Expect Script for SSH有关如何使用 Expect 的示例(此处用于自动化 ssh )。

关于linux - 如何在 bash 脚本中获取控制台输入以使用 SSL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25772670/

相关文章:

Bash:如何检测 "repeat"标志,例如 -vvv?

facebook - FQL photo 和 photo_src 表 src 使用 http 但不使用 https

c++ - eclipse helios 找不到 g++、gdb、$PATH、make

c# - 使用 Rock Ridge 扩展将文件添加到 ISO

php - 在 Linux 中配置虚拟主机和本地主机重定向到 xampp 文件夹

linux - libelf 破坏 ARM elf 二进制文件

linux - 在Linux CLI中按位置替换特定行上的特定字符

node.js - 使用 Node.js 从 'named pipe'/fifo 读取

google-app-engine - GWT SSLContext.setDefault(SSLContext) 码头异常

CakePhp、Xampp 和 SSL "Internal error has occured"