Automated Deploy (RSYNC) with key password prompt


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/perl -w
  2. # @autor gpupo <[email protected]>
  3. # Use on project deployment with ssh keys prompt
  4. # Requeriment: (test on debian) libfile-slurp-perl libfile-read-perl libexpect-perl
  5. # You need to create a file called .myK containing the password of your key in your home directory. Not the example of safety, sorry:)
  6. use Expect;
  7. use File::Read;
  8. $path = $ENV{"HOME"} ."/.myK";
  9. $file = read_file($path);
  10. $prompt = ".ssh/id_rsa':";
  11. $exclude = $ENV{"HOME"} . '/wProjects/config/rsync_Cpanel_exclude.txt';
  12. $cmd = 'rsync -r -t -v -L -z --progress --stats --exclude-from=' . $exclude . " @ARGV";
  13. print "\n===== Executing:\n$cmd\n";
  14. $exp = new Expect();
  15. $exp->raw_pty(1);
  16. $exp->spawn($cmd);
  17. $exp->expect(10000, [ $prompt => sub { $_[0]->send("$file\n"); } ]);
  18. print "\n";
  19. $exp->soft_close();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.