Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8510059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:36:08+00:00 2026-06-11T03:36:08+00:00

I have a php script which contains su. when I run it in shell

  • 0

I have a php script which contains su. when I run it in shell it ask for root password and works well. but now I want make an interface for it. as you know all command in php-apache runs as www-data user and this user doesn’t have specified password or it’s not in sudoers. so I can’t use “echo pass | sudo -S …” because I don’t know what is www-data’s password and It is not logical on every server set password for www-data or add it in sudoers+nopass, is it?

What solution can you suggest to solve this problem?

one of my commands:

su -c \"/usr/sbin/dmidecode -s baseboard-serial-number | tr \  \-\"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:36:09+00:00Added an answer on June 11, 2026 at 3:36 am

    phpseclib should be best library choice as it does not requires any additional extensions.

    <?php
    include('Net/SSH2.php');
    
    $ssh = new Net_SSH2('example.com');
    if (!$ssh->login('user', 'pass')) {
        exit('Login Failed');
    }
    
    echo $ssh->exec('whoami');
    echo $ssh->exec('pwd');
    ?>
    

    Another alternative is libssh2, but it has to be compiled separately and is notoriously difficult to setup/use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP search script which I've altered slightly and works well for
I have a PHP-script originally developed on Ubuntu, which now has to run on
I have a PHP script which works fine in PHP 5, but not in
I have a very large script which contains a lot of php files, so
I have simple script which contains two pages - script.php and function.php. Script.php contains
I have a PHP script which contains a shell_execute() and the command it executes
I have a php script, that contains some text file writing operation. Now if
I have this PHP script which i'm grabbing images from a directory and displaying
I have a php script which saves the original image, then resizes it -
I have a PHP script which creates and listens on a port for connections

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.