dongyizhuang0134
dongyizhuang0134
2018-08-04 09:44

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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • doubi4491 doubi4491 3年前

    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.

    点赞 评论 复制链接分享