2018-08-04 09:44
浏览 375

Laravel SSH连接

I have a question regarding a task that I want to accomplish. I have a website whose back-end is written in laravel 5 and using mysql as a database. On the website dashboard there is tab named status. What I wanted to do is that when I click on the status tab it will fetch a server IP from the table that is already present in the database. Make ssh connection on that server IP, execute a bash command on the remote terminal and show the output of the command on the dashboard. Is it possible to do in laravel? I have seen 2 packages that are available in laravel for ssh connection. One is ssh by laravelcollective and other is envoy by laravel but i am unable to figure out how they will accomplish this task. Any help in this regard would be highly appreciated. Thanks.

图片转代码服务由CSDN问答提供 功能建议

我有一个关于我想要完成的任务的问题。 我有一个网站,其后端用 laravel 5 编写,并使用 mysql 作为数据库。 在网站信息中心上有一个名为状态的标签。 我想要做的是,当我点击状态标签时,它将从数据库中已存在的表中获取服务器IP。 在该服务器IP上建立ssh连接,在远程终端上执行bash命令并在仪表板上显示命令的输出。 是否可以在laravel中执行? 我已经看到2个可用于ssh连接的laravel包 。 一个是 ssh laravelcollective ,另一个是特使 laravel 但是我无法弄清楚他们将如何完成 这个任务。 在这方面的任何帮助将受到高度赞赏。 谢谢。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doubi4491 2018-08-04 09:51

    One way to accomplish this is by using the ssh2_connect which allows you to create the connection and then you can execute commands and retrieve the results in via callbacks

    Here you have the full documentation which comes with nice examples on everything I said before.

    打赏 评论

相关推荐 更多相似问题