use Net::SSH::Any;
use Data::Dumper;
# my $ssh2 = Net::SSH::Any->new(..);
my $cmd = "sudo -u postgres -p password perl -e 'print `whoami`'";
print Dumper $ssh2->capture({timeout => 15}, $cmd);
我想sudo
遠程主機上,但不要在代碼具有命令行上的明文口令像上面的想法一樣。有其他選擇嗎?避免密碼
[密碼的須藤](http://serverfault.com/questions/160581/ (當然有安全隱患) – ThisSuitIsBlackNot
@ThisSuitIsBlackNot tnx,但我不能改變sudo行爲 –
還有'-S'開關看起來很有希望嗎? http://superuser.com/a/67766/223664 –