If I understand you correctly, I think I can suggest a more reliable solution, but first please answer these questions:
- How many local and remote hosts are involved with use of this script?
- Are you the only person to use the hosts?
- Is the goal to run a command on the remote host and take actions on the remote host with no logging or side effects to be taken on the local host?
Update: While awaiting your answer, I'll outline my solution which assumes the answer to question three is NO:
- Write a Perl program on the remote host(s) of interest which does all you need. The program should require the login user name of the remote user if that is required.
- Ensure all persons needing access to the program and the remote hosts have working access via ssh.
- If the remote program needs to run as root or other privileged user, either make the script setuid or write a wrapper setuid program which will run the required script. Put the script in each user's home directory to be executed via ssh which will run the setuid program. (If you need multiple user access it would probably be easier to put the one or two programs in a group-owned directory.)
With the above you can now do something like this on your local host:
$ ssh user@remotehost progb --arg1=X --arg2=Y
and all will be taken care of on the remote host. I use such a process to update my remote Apache web server which needs root privileges but which does not allow root access via ssh. I use the setuid wrapper script so I can more easily modify the actual script which does all the work and send it to the remote host as an ordinary user. The setuid program doesn't need updating much so the bother of logging in and acting as root doesn't happen very often after the process is working as desired.
Note: wherever I have said "setuid" I believe should be "setgid" for multiple users, but I have no experience with that.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.