Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Passing Password through Perl Script

by Amarendu (Initiate)
on Aug 09, 2012 at 09:46 UTC ( #986466=perlquestion: print w/replies, xml ) Need Help??
Amarendu has asked for the wisdom of the Perl Monks concerning the following question:

I want to pass a password through a Perl script. I am basically writing a script to execute commands on Linux terminal.

Replies are listed 'Best First'.
Re: Passing Password through Perl Script
by marto (Archbishop) on Aug 09, 2012 at 09:54 UTC
      I don't exactly need that you have specified. I don't want to prompt the user for a password. In my local system I run say two commands like "su hduser" which prompts me for a password and entering the password I get logged in as hduser. I just need to automate this thing using a script in my local system only so that I don't have to do this from the command line. Thanks in advance any help would be of great help.
        You can always configure /etc/sudoers to not require passwords -- either for all commands or for a list of specified commands.
Re: Passing Password through Perl Script
by flexvault (Monsignor) on Aug 09, 2012 at 09:52 UTC


    What is the question?

    Do you need to encrypt the password?

    Do you need to save it in a safe place, etc??

    Thank you

    "Well done is better than well said." - Benjamin Franklin

      I have a user named "hduser" and the password of the user is say "xyz123". Now I need a automated script for it so that I can get logged in as hduser without prompting for it's password. For example I have written a perl script as follows: #!/usr/bin/perl system ("su hduser && <xyz123>"); I need to set the user password for hduser. Please help urgently. Thanks a lot in advance.

        If you want your script to run with the privileges of user "hduser" without having to enter that user's password you should probably investigate Secure Shell.



Re: Passing Password through Perl Script
by Anonymous Monk on Aug 09, 2012 at 09:48 UTC

    Type password in search box and have fun :)

Re: Passing Password through Perl Script
by Anonymous Monk on Aug 09, 2012 at 18:31 UTC
    Use SSH with digital certificates for password-free login. Be sure that each computer has its own unique certificate. It's also a good idea to password-protect (encrypt...) each certificate and to use an ssh-agent to store those keys. Tighten down the scenario as tightly as you can ... if you know IP-addresses, lock the connection to them.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://986466]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2018-04-26 22:13 GMT
Find Nodes?
    Voting Booth?