简体   繁体   中英

How can I ssh into a remote host with Perl?

I want to write a Perl script which ssh's into a remote host, prompts for password before running some commands on remote host and parse the output in the local Perl script. Any help or pointers on this? Thanks!

There is Net-SSH-Perl
Some notes on usage .


If you are discouraged with the module and need an easy way out,
you could directly invoke SSH on the shell.

perl -e {`ssh user@server "command"`}

should work...


I hope you intend to let the SSH use its passwords and not implement 'security' some yourself.
Could also consider public key authentication .

I think perhaps the tool you want is not Perl but Expect . It is designed exactly for interacting with command-line software programmatically. It is written in Tcl , which is a language somewhat simpler than Perl, but broadly in the same family and not difficult to learn.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM