use strict; use Net::SSH::Perl; use Net::SSH::Perl::Agent; use Net::SSH::Perl::Key; my $agent = Net::SSH::Perl::Agent->new(1); my $iter = $agent->identity_iterator; while (my($key, $comment) = $iter->()) {        ## Do something with $key. print ("Key: " , $key , ":" , $comment ,"\n"); print ("test\n"); print ("-----------------------------------------\n\n"); my $host = "iksa-hop1"; my $user = "daitdsi"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user); my $cmd = "hostname"; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print ("Erster Host: $stdout\n"); $cmd = ". /home/daitdsi/.bashrc; ssh -i /home/daitdsi/.ssh/authorized_keys daitdsi\@appsvc1 hostname"; ($stdout, $stderr, $exit) = $ssh->cmd($cmd); print ("-----------------------------------------\n\n"); print ("Zweiter Host: $stdout\n"); print ("-----------------------------------------\n\n"); print ("err:\n$stderr\n"); print ("-----------------------------------------\n\n"); print ("exi:\n$exit\n"); } exit(0);