【发布时间】:2014-04-12 09:53:16
【问题描述】:
我正在编写一个应用程序,它需要使用 revssh 脚本在远程 Raspberry PI 上运行命令。 revssh 是一个自定义脚本,它在某种程度上实现了 Revssh 协议概念。它使用 ssh 反向隧道将命令从服务器发送到客户端。
我正在使用 Ruby 2.1,我尝试使用 IO.popen 执行此操作,但它不起作用,因此我尝试了以下操作:
# revssh (short for reverse ssh ) enables the execution of remote commands
# from the server on connected clients, like the 'psu_pi_analytics' here. but it requires
# to enter a root password each time you want to run a command using 'revssh -c'
IO.popen('revssh -c psu_pi_analytics uname -a', 'w+') do|io|
io.puts 'password' # enter the password when prompted
puts io.gets
end
如果要执行的命令在本地计算机上运行,则此代码有效,但在我的情况下则无效。 所以有任何想法或建议。
这里重要的是如何处理revssh脚本使用ssh创建的新连接,如果脚本直接从终端运行,则在终端中管理。
编辑:
不工作是指它仍然提示输入密码,即使我将密码输入 io。
【问题讨论】:
-
我不熟悉 revssh。你的操作系统是什么?
-
@WayneConrad ,revssh 是一个自定义脚本,在某种程度上实现了 Revssh 协议概念。您可以将其视为反向的 ssh 命令,从服务器到客户端。这里重要的是如何使用 ssh 处理这个脚本创建的新连接,如果脚本是直接从终端运行的,则在终端中进行管理。
-
谢谢,@Nafaa。该信息可能应该添加到问题中。顺便说一句,“不工作”是什么意思?发生什么了?请点击“编辑”并将其添加到您的问题中。