Skip to content

Commit 35e0c5b

Browse files
westnet-pauljfcoz
authored andcommitted
Add a --sshuser argument
It may be that the user running the command is different from the SSH user on the server. This argument allows specification of the SSH username.
1 parent 312d197 commit 35e0c5b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

postgresqltuner.pl

+7-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
my $help=0;
7575
my $work_mem_per_connection_percent=150;
7676
my @Ssh_opts=('BatchMode=yes');
77+
my $ssh_user=undef;
7778
my $ssd=0;
7879
my $nocolor=0;
7980
my $skip_ssh=0;
@@ -96,6 +97,7 @@
9697
"help" => \$help,
9798
"wmp=i" => \$work_mem_per_connection_percent,
9899
"sshopt=s" => \@Ssh_opts,
100+
"sshuser=s" => \$ssh_user,
99101
"ssd" => \$ssd,
100102
"nocolor" => \$nocolor,
101103
"skip-ssh" => \$skip_ssh,
@@ -234,7 +236,11 @@ sub usage {
234236
} elsif ($host =~ /^::1$/) {
235237
$os_cmd_prefix='';
236238
} elsif ($host =~ /^[a-zA-Z0-9._-]+$/) {
237-
$os_cmd_prefix="ssh $ssh_opts $host ";
239+
if (defined($ssh_user)) {
240+
$os_cmd_prefix="ssh $ssh_opts $ssh_user\@$host ";
241+
} else {
242+
$os_cmd_prefix="ssh $ssh_opts $host ";
243+
}
238244
} else {
239245
die("Invalid host '$host'");
240246
}

0 commit comments

Comments
 (0)