Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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.

Comment on Passing Password through Perl Script
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 flexvault (Prior) 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 marto (Bishop) 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 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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2015-07-06 12:05 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (73 votes), past polls