sshmenu

Prosty skrypt ułatwiający użycie konsolowego ssh.

#! /usr/bin/perl
  1. use Switch;
  2. $cnt=-1;
  3. @def = (\@host, \@ip, \@usr, \@port);
  4. @def = (
  5. ["hostname","192.168.0.5","root","22"],
  6. ["hostname2","172.16.0.1","root","22"]
  7. #[""""""""22"],
  8. #[""""""""22"],
  9. #[""""""""22"],
  10. #[""""""""22"],
  11. #[""""""""22"],
  12. #[""""""""22"],
  13. #[""""""""22"],
  14. );
  15.  
  16. foreach (@def) {
  17. $reff = $_;
  18. $cnt+=1;
  19. print $cnt.". ".$reff>[0]."\n";
  20. }
  21.  
  22. print ":";
  23. $ch=<>;
  24. $ref = $def[$ch];
  25. $cmd = "ssh $ref->[2]".'@'."$ref->[1] -p $ref->[3]";
  26.  
  27. system($cmd)==0 or die "Error: could not '$cmd'";
Posted on February 22, 2009 at 4:19 pm by admin · Permalink
In: skrypty

Leave a Reply