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 –