Ruby Net:SSH控制大师?
我目前有一个 Ruby (Rails) 应用程序,需要建立大量的短 SSH 连接。使用 Ruby Net::SSH 库可以正常工作,只是每次我想发出命令时应用程序都必须登录并协商密钥,这太慢了。
有没有办法使用 Ruby Net::SSH 启用 Control Master?在命令行测试中,这使得登录(第一次登录后)非常快,因为连接已经打开(密钥已协商等)。
如果 Net::SSH 无法做到这一点,有人可以建议一个可以做到这一点的替代库吗?
我想这一定是一个常见的要求,所以希望有人能提供帮助。
谢谢!
I currently have a Ruby (Rails) application that needs to make a lot of short SSH connections. This works fine using the Ruby Net::SSH library, except that the app has to log in and negotiate keys every time I want to make a command, which is too slow.
Is there a way to enable Control Master with Ruby Net::SSH? In testing on the command line, this makes logins (after the first one) very fast, since the connection is already open (keys are negotiated etc.).
If there is no way to do this with Net::SSH, can anybody suggest an alternative library that could do it?
I imagine this must be a common requirement, so hopefully someone can help.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不保持连接打开呢?
ssh 调用是虚拟的,因为我不知道 api,但它达到了其目的:
每个线程将获得一个 ssh 连接,或者如果您的应用程序与乘客一起部署,则每个进程将有一个连接并将重用它。
是你想要的吗?
Why not just keeping the connection open ?
The ssh calls are dummy as I don't know the api but it serves its purpose:
You will get one ssh connection per thread or if your application is deployed with passenger each process will have one connection and will reuse it.
Is it what you want ?
您可以准确指定您想要哪种加密协议来最大程度地减少握手,但是,是的,如果您需要扩展它,SSH 可能会有点慢。
一个非常有趣的做法是 http://saltstack.org/ 它在顶部实现了自己的“ssh”替代方案0mq,使得在多个服务器上运行并行命令变得超快,显然不会遇到与 ssh 相关的性能问题(例如厨师等)的相同问题。也许您可以在 salt 的基础上这样做吗?
You can specify exactly what kind of encryption protocol you want as to minimize the handshake, but well, yeah SSH can be a bit slow if you need to scale it up.
A really interesting take on this is http://saltstack.org/ it has implemented it's own "ssh" alternative on top of 0mq, making it super-fast to run parallel commands on multiple servers, apparently not having the same problems of ssh-related performance issues such as with chef etc. Maybe you could build upon salt do do this?