如何从“ Ruby”中的一个现有ssh会话创建新的ssh连接

问题描述

我正在尝试从也位于远程计算机上的现有ssh会话向远程计算机发起一个ssh会话。通过手动使用腻子,我将执行以下命令。

login as: root
[email protected]'s password:
Last login: Mon Oct  5 11:19:51 2020 from 192.168.122.254
root@host-1:~#
root@host-1:~# ssh [email protected]
[email protected]'s password:
Last login: Mon Oct  5 10:25:47 2020 from 192.168.122.31
root@host-2:~#
root@host-2:~# cd /var/phone-home/
root@host-2:/var/phone-home# ls -lrt*

我已经尝试过下面的代码,但是我无法提供密码

Net::SSH.start(192.168.122.31,root,:timeout => 1,:password => @pass) do |ssh_connection|
ssh_connection.exec!("ssh [email protected]")

还有什么更好的方法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)