Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added passphrase

  • Loading branch information...
commit c5f26ac48a67e624077df870a67db40add39ca9a 1 parent f8803f5
@liseen liseen authored
View
3  README
@@ -47,6 +47,9 @@ SYNOPSIS
# or prompt for password if sudo required...
$ atnodes 'sudo apachectl restart' '{ps}' -w
+ # use -P to prompt for passphrase (no echo back)
+ $ atnodes hostname '{ps}' -u agentz -P
+
# run sudo command if tty required...
$ atnodes -tty 'sudo apachectl restart' '{ps}'
View
25 bin/atnodes
@@ -19,7 +19,7 @@ if (!@ARGV) {
}
my $list_hosts_only = 0;
-my ($user, $port, $timeout, $verbose, $ask_for_pass);
+my ($user, $port, $timeout, $verbose, $ask_for_pass, $ask_for_passphrase);
my $concurrency = 20;
my (@cmd, @exprs, $ssh_cmd);
$ssh_cmd = $ENV{SSH_BATCH_SSH_CMD};
@@ -57,6 +57,8 @@ for (@ARGV) {
$verbose = 1;
} elsif ($group eq 'w') {
$ask_for_pass = 1;
+ } elsif ($group eq 'P') {
+ $ask_for_passphrase = 1;
} elsif ($group eq 'c') {
$fetch_value = sub { $concurrency = shift };
} elsif ($group eq 'ssh') {
@@ -122,8 +124,19 @@ if ($list_hosts_only) {
exit(0);
}
-my $password;
-if ($ask_for_pass) {
+my ($passphrase, $password);
+if ($ask_for_passphrase) {
+ print STDERR "Passphrase:";
+ ReadMode(2);
+ while (not defined ($passphrase = ReadLine(0))) {
+ }
+ ReadMode(0);
+ print "\n";
+ chomp $passphrase;
+ if (!$passphrase) {
+ die "No passphrase specified.\n";
+ }
+} elsif ($ask_for_pass) {
print STDERR "Password:";
ReadMode(2);
while (not defined ($password = ReadLine(0))) {
@@ -151,6 +164,7 @@ while (1) {
defined $timeout ? (timeout => $timeout) : (),
defined $user ? (user => $user) : (),
defined $port ? (port => $port) : (),
+ defined $passphrase ? (passphrase => $passphrase) : (),
defined $password ? (password => $password) : (),
defined $ssh_cmd ? (ssh_cmd => $ssh_cmd) : (),
);
@@ -276,6 +290,7 @@ OPTIONS:
-u <user> User account for SSH login.
-v Be verbose.
-w Prompt for password (used for login and sudo).
+ -P Prompt for passphrase (used for login).
-tty Pseudo-tty.
_EOC_
if ($exit_code == 0) {
@@ -312,6 +327,9 @@ atnodes - Run commands on clusters
# or prompt for password if sudo required...
$ atnodes 'sudo apachectl restart' '{ps}' -w
+ # use -P to prompt for passphrase (no echo back)
+ $ atnodes hostname '{ps}' -u agentz -P
+
# run sudo command if tty required...
$ atnodes -tty 'sudo apachectl restart' '{ps}'
@@ -338,6 +356,7 @@ atnodes - Run commands on clusters
-u <user> User account for SSH login.
-v Be verbose.
-w Prompt for password (used for login and sudo).
+ -P Prompt for passphrase (used for login).
-tty Use pseudo-tty.
=head1 PREREQUISITES
View
22 bin/tonodes
@@ -18,7 +18,7 @@ if (!@ARGV) {
}
my $list_hosts_only = 0;
-my ($user, $port, $timeout, $verbose, $ask_for_pass, $recursive, $use_glob);
+my ($user, $port, $timeout, $verbose, $ask_for_pass, $ask_for_passphrase, $recursive, $use_glob);
my ($bwlimit, $use_rsync);
my $concurrency = 20;
my (@files, @exprs);
@@ -59,6 +59,8 @@ for (@ARGV) {
$verbose = 1;
} elsif ($group eq 'w') {
$ask_for_pass = 1;
+ } elsif ($group eq 'P') {
+ $ask_for_passphrase = 1;
} elsif ($group eq 'r') {
$recursive = 1;
} elsif ($group eq 'g') {
@@ -176,8 +178,19 @@ if ($list_hosts_only) {
exit(0);
}
-my $password;
-if ($ask_for_pass) {
+my ($passphrase, $password);
+if ($ask_for_passphrase) {
+ print STDERR "Passphrase:";
+ ReadMode(2);
+ while (not defined ($passphrase = ReadLine(0))) {
+ }
+ ReadMode(0);
+ print "\n";
+ chomp $passphrase;
+ if (!$passphrase) {
+ die "No passphrase specified.\n";
+ }
+} elsif ($ask_for_pass) {
print STDERR "Password:";
ReadMode(2);
while (not defined ($password = ReadLine(0))) {
@@ -206,6 +219,7 @@ while (1) {
defined $timeout ? (timeout => $timeout) : (),
defined $user ? (user => $user) : (),
defined $port ? (port => $port) : (),
+ defined $passphrase ? (passphrase => $passphrase) : (),
defined $password ? (password => $password) : (),
);
if ($ssh->error) {
@@ -342,6 +356,7 @@ OPTIONS:
-u <user> User account for SSH login.
-v Be verbose.
-w Prompt for password (used mostly for login and sudo).
+ -P Prompt for passphrase (used mostly for login).
_EOC_
if ($exit_code == 0) {
print $msg;
@@ -394,6 +409,7 @@ tonodes - Upload local files/directories to remote clusters
-u <user> User account for SSH login.
-v Be verbose.
-w Prompt for password (used mostly for login and sudo).
+ -P Prompt for passphrase (used mostly for login).
-rsync Use "rsync" to transfer files.
-archive Enable rsync archive mode
View
1  t/atnodes.t
@@ -54,6 +54,7 @@ OPTIONS:
-u <user> User account for SSH login.
-v Be verbose.
-w Prompt for password (used for login and sudo).
+ -P Prompt for passphrase (used for login).
-tty Pseudo-tty.
--- status: 1
View
2  t/tonodes.t
@@ -63,6 +63,7 @@ OPTIONS:
-u <user> User account for SSH login.
-v Be verbose.
-w Prompt for password (used mostly for login and sudo).
+ -P Prompt for passphrase (used mostly for login).
--- status: 1
@@ -168,6 +169,7 @@ OPTIONS:
-u <user> User account for SSH login.
-v Be verbose.
-w Prompt for password (used mostly for login and sudo).
+ -P Prompt for passphrase (used mostly for login).
--- err
--- status: 0
Please sign in to comment.
Something went wrong with that request. Please try again.