Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Accessing UNIX server using Net::SSH

by hraj (Novice)
on Aug 24, 2006 at 11:04 UTC ( [id://569334]=perlquestion: print w/replies, xml ) Need Help??

hraj has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have to connect to a UNIX server from my Perl script. I have tried Net::SSH, but it is giving an error message saying "Authentication Failed". I guess, since i didn't supplied the Password it failed. In the Net::SSH user manual it says we can supply password only using DSA or RSA keys.

Can anyone tell me how to supply password using DSA or RSA keys in Net::SSH module.

Note: Since i am using Windows platform i can't use Net::SSH::Perl or Net::SSH::W32Perl modules.

Thanks in Advance,

Hemaraj

Replies are listed 'Best First'.
Re: Accessing UNIX server using Net::SSH
by marto (Cardinal) on Aug 24, 2006 at 11:18 UTC
    "Can anyone tell me how to supply password using DSA or RSA keys in Net::SSH module."

    The Net::SSH documentation covers this topic in the FAQ section. Please read the documentation.

    "Note: Since i am using Windows platform i can't use Net::SSH::Perl or Net::SSH::W32Perl modules."

    If your issue is that you do not have a compiler, the README for Net::SSH::W32Perl states:

    "NOTE: I've made ppms (binaries) available for this and most of it's required modules at Http://www.soulcage.net/ppds/. The following command should install everything you need.
    ppm install --location=http://www.soulcage.net/ppds Net::SSH::W32Perl"

    Or you may want to look at Camelpack, a "Windows installer to setup a complete Perl development environment including support for building C/C++ extensions."

    Martin
Re: Accessing UNIX server using Net::SSH
by ForgotPasswordAgain (Priest) on Aug 24, 2006 at 11:28 UTC
    Can anyone tell me how to supply password using DSA or RSA keys in Net::SSH module.

    Note that Net::SSH requires the `ssh` command, so presumably you have cygwin installed and ssh installed in it. Then, as the manual says, use ssh-keygen. You can find plenty of tutorials describing how to do passwordless logins. Basically you'll append id_rsa.pub or id_dsa.pub (your public key) onto the remote system's .ssh/authorized_keys file (if you have ssh-copy-id, it's even easier).

    I'm not sure why you say Net::SSH::Perl or Net::SSH::W32Perl won't work because you're on Windows, though.

Re: Accessing UNIX server using Net::SSH
by eXile (Priest) on Aug 24, 2006 at 13:52 UTC
    If you have a ssh binary on your system that works, and you can log in to the other machine manually, you could use Expect to automate the exact process you'd use as if you where logging in manually.
Re: Accessing UNIX server using Net::SSH
by mantra2006 (Hermit) on Aug 24, 2006 at 14:43 UTC
    Hey


    Before writing perl program to access unix system first try
    to see you can access unix machine using ssh from your command
    $ prompt..if you were able to access it then
    you shouldn't have any issues using Net::SSH.
    DSA or RSA keys is something like public and private keys
    If I am correct you will supply one key to connect to
    unix machine and that machine will verify the key you supplied
    and if its correct then you will be given access to the system
    its password less authentication

    Before digging into Net::SSH check to see you are able to access manually

    Sridhar
Re: Accessing UNIX server using Net::SSH
by hraj (Novice) on Aug 25, 2006 at 05:54 UTC

    Hi,

    Thanks for all your posts.

    Martin, Net::SSH documentations says just these lines in its documentation.

    "You don't. Use RSA or DSA keys. See the ssh-keygen(1) manpage"

    I don't know how to use RSA or DSA keys in Net::SSH module, that's why i posted this query.

    I have installed Net::SSH::Perl and Net::SSH::W32Perl in my maching using PPM. But, when i try to run using these modules i get the following error message.

    "The getpwuid function is unimplemented at C:/Perl/site/lib/Net/SSH/Perl.pm line 110."

    I also suffered in the internet and found out that getpwuid is not implemented for Win32 System. See http://www.perl.com/doc/FAQs/nt/perlwin32faq5.html.

    I have ssh command in my machine. I have tried connecting the UNIX server manually (i.e. giving the password details manually) and it is working fine.

    Now, my question is how to connect to UNIX server using Net::SSH module with DSA or RSA keys?

    Once again, thanks for all your help.

    Hemaraj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://569334]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-03-29 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found