Hi guys, I have another problem now, When I try sending my public key to my servers, in some I get the info below, if I get the permission denied in more than 2 servers the program remain in loop. Is there any solution to pass the permission denied and jump to the next server from array?

ecosta@trr-ntripc-alp's password:

Permission denied, please try again.

ecosta@trr-ntripc-alp's password:

/usr/local/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/local/bin/ssh-copy-id: INFO: 2 key(s) remain to be installed -- if you are prompted now it is to install the new keys

ecosta@trr-ntripc-bet's password:

/usr/local/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

ecosta@trr-ntripc-alp's password:

Permission denied, please try again.

ecosta@trr-ntripc-alp's password:

Permission denied, please try again.

ecosta@trr-ntripc-alp's password:

foreach my $hostname(@_){ 163 # print $hostname,"\n"; 164 165 my $scp_exp = new Expect; 166 # Run the copy command. 167 $scp_exp->spawn("ssh-copy-id $user\@$hostname") or die " +Cannot spawn ssh-copy-id: $!\n"; 168 $scp_exp->log_file("./autossh-copy-id.log"); 169 $scp_exp->expect(2, 170 [qr/\(yes\/no\)\?\s*$/ => sub { $scp_ +exp->send("yes\n"); exp_continue } ], 171 [qr/assword:\s*$/ => sub { $scp_exp-> +send("$pass\n"); exp_continue; } ], 172 #[timeou => sub { die "Permission den +ied.\n"; } ], '-re','$'); 173 #[qr/Permission denied, please try ag +ain\s*$/ => sub { exp_break; } ], 174 #[EOF => sub {my $exph = shift; my $e +rror = "Error: Could not login, EOF!"; &logerror($error, $hostname); + exp_break; } ], 175 #[timeout => sub {$exph = shift; $err +or = "Error: Could not login, timeout!"; &logerror($error, $hostname) +; exp_break; }],'-re', '$'); 176 ); 177 #$scp_exp->send("\cC"); 178 # $scp_exp->interac +t(); 179 $scp_exp->hard_close(); 180 }

Thanks guys


In reply to Eternal Loop by edualfaia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.