If I understand, do you want to execute one script that is on another server via ssh? Right? If this is the case, you need to log in to server number two without a password. It is easy.
First way : All you have to do is generate ssh keys (no password). Here is how you can do it . Second method (better): I assume that you do not have permission to execute the script on server number two. This is easy to solve if you have access to a second server. Here's how you do it:
- Enter visudo
- Add this line to the end of the file.
apache ALL = (user) NOPASSWD: script_path
Example
apache ALL=(clamav) NOPASSWD: /usr/bin/clamscan
In parentheses you enter a user who has permission to execute your script. srcipt_path is in the above example / usr / bin / clamscan.
- With a twist from the server, you open some file on the server two (lts call it script.php)
- Modify script.php and add
$ do = exec ("some_script some_arguments")
and thatโs it.
source share