How to Interact with the PHP shell indirectly?



  • Hi all. My ultimate goal is to interact with the pfsense PHP shell through Ansible. Because at the moment I am unable to do that I am proceeding step by step. Next is some background and my questions.

    I have changed my privileges on the pfsense user management (through web-interface) in a way that when I ssh the pfsense box I am not prompt with the starting menu but I am already inside the shell (that would be option 8 at the start menu). From here I run "/usr/local/sbin/pfSsh.php" which starts the PHP shell with which I can directly interact with.

    Question 1 : Is there a way to run PHP commands from the shell (not the PHP shell)?  For example using "/usr/local/sbin/pfSsh.php" + "command"
    Question 2 : Is there a way to redirect the output of a potential "/usr/local/sbin/pfSsh.php" + "command" to a file?

    PS. That is the way I am taking to interact with the PHP shell through Ansible. If you have some other idea or suggestion I would be glad to hear that.

    Thank you



  • this is what i do when i want to use the dev shell from console:

    -create a file that has the required php code inside
    -place the file in /etc/phpshellsessions
    -use the playback argument of pfSsh to run your code

    see post below for an example (it includes writing to a file)
    https://forum.pfsense.org/index.php?topic=109206.msg608279#msg608279

    I must say, i'm not an expert in these things, but i find it to be the easiest way to use the devshell from console .
    for quick hacking, you can also echo & pipe commands towards the devshell.



  • @heper Thank you for your reply. I am following the example of the link you posted. Question:  Since I cannot use sudo to write my test file, how else can I create a file under /etc/phpshellsessions?

    –------

    I actually found the way by installing the sudo package through pfsense web-interface..