Re: run ssh on linux through php???

From: Date: Mon, 16 Sep 2002 18:21:43 +0000
Subject: Re: run ssh on linux through php???
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-116554@lists.php.net to get a copy of this message
Everything Chris says is right, I just wanted to add a little information. First, if you use an expect script to do anything with SSH, you have to leave the password in plain text in the expect script. Not good practice. If you want to run some sort of SSH process (eg, an rsync command using ssh instead of rsh), look into using ssh_agent. You can "pre-authorize" a connection from a particular user to a remote system. Remember that you'll either have to have an ssh_agent client running as the user your web servers runs as, or synchronize it in some other manner. You also won't be able to have the ssh_agent process start up automatically on reboot unless you do something like using a null password for the ssh key - also not a good practice. In any event, ssh_agent gives you the capability to run unattended processes over ssh. This still isn't going to give you a shell via a web browser, but why would you want that? ..michael.. On Sun, 2002-09-15 at 16:49, Chris Shiflett wrote: > Well, your problem is that ssh is interactive. You can call ssh passing > the password on the command line to get around your immediate problem, > but what good does it do for PHP to connect via ssh, only to exit prior > to you seeing anything in the Web browser? > > Remember that PHP completes execution prior to the response being sent > from the Web server to your browser. Thus, PHP is finished by the time > you see a Web page. If you want to do anything interactive, it either > has to happen on the client side (such as a Java applet), or it has to > somehow be able to coexist with the transactional nature of the Web. > > What you might want to look into are ways of doing whatever you want to > do in a single command. For example, if you just want to execute a > command on a remote machine, there are ways to do this aside from an > interactive login. > > Finally, if what you need to do absolutely must be done interactively, I > suggest looking into the Expect scripting language. An Expect script can > be executed by PHP, and you will be "waiting for a response..." until it > finishes. > > Happy hacking. > > Chris > > michael wrote: > > >i want to run ssh through php and any browser.i have tried something with > >the functions: system(),shell_exec(). > >e.g. shell_exec(sss -l username localhost). > > > >the problem is that my browser doesn't return something.So, i can't login > >because i can't give the password. > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#116554) next »