从PHP启动交互式SSH bash会话 [英] Launch interactive SSH bash session from PHP
问题描述
我正在使用PHP编写常见服务器管理任务的快捷方式(我正在使用deployer.org,但这并不重要).我想添加一个任务,用于在SSH进入服务器后启动交互式bash提示.例如,您将运行"./dep ssh"(其中"dep"是PHP脚本),其效果与运行例如从终端"ssh user @ server".有没有办法在PHP中做到这一点?就上下文而言,我大约有5台服务器经常要SSH进入,读取日志或复制文件等.为此,我需要快捷方式.
I'm using PHP to write shortcuts for common server admin tasks (I'm using deployer.org but this shouldn't be important). I want to add a task for starting an interactive bash prompt after SSHing into a server. For example, you would run "./dep ssh" (where "dep" is a PHP script) and this would have the same effect as running e.g. "ssh user@server" from the terminal. Is there a way to do this in PHP? For context, I have about 5 servers that I frequently want to SSH into, or read logs, or copy files etc. so I want shortcuts for this.
我能得到的最接近的东西是这样的:
The closest I've been able to get is something like this:
$ph = popen("bash","w");
while(($line = fgets(STDIN)) !== false){
fputs($ph,$line);
}
pclose($ph);
这使您可以向bash发送命令或从bash发送命令,但是看不到正常的bash提示符或获得制表符补全.我需要这样的东西,但所有正常的bash功能都可以正常工作.
This lets you send commands to and from bash but you don't see the normal bash prompt or get tab completion. I need something like this but with all the normal bash features working.
推荐答案
如果您只是想在Web浏览器中进行SSH,那么您可能正在寻找以下产品之一:
If you are simply looking to do SSH in web-browser this is what you are may be looking for one of the following products:
- 针对Chrome和Chromium的Google的Secure Shell扩展
- 任何人
- Ajaxterm
- 一号门
- webmux
- WebShell
- EC2Box
- KeyBox
- KeyBox-OpenShift
- Mist.io
此处是您可能想要查看的链接.
这篇关于从PHP启动交互式SSH bash会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!