如何通过CPAN模块Net-OpenSSH设置GSSAPIAuthentication和GSSAPIDelegateCredentials属性

时间:2015-09-16 05:47:24

标签: perl ssh cpan openssh

我正在尝试通过模块http://search.cpan.org/~salva/Net-OpenSSH-0.62/创建一个ssh句柄。我尝试将GSSAPIAuthenticationGSSAPIDelegateCredentials设置为"否",但是如果我的.ssh/config是这样的话,这些设置就不会生效:

$ cat myusername/.ssh/config 

Host *
    CheckHostIP no
    StrictHostKeyChecking no
    HashKnownHosts no
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no
    UserKnownHostsFile /dev/null
    LogLevel ERROR

这是我尝试设置GSSAPIAuthenticationGSSAPIDelegateCredentials的方法。还有一种方法可以在open ssh构造函数中给出-F选项,这样默认情况下ssh使用其他配置文件而不是使用一个用户我的用户名吗?

$self->{ssh} = Net::OpenSSH->new($host,
user => $username,
passwd => $password,
timeout => $timeout,
default_stderr_discard => 1,
kill_ssh_on_timeout => 1,
master_opts => [-o => "UserKnownHostsFile=/dev/null",
    -o => "GSSAPIAuthentication=no", 
    -o => "GSSAPIDelegateCredentials=no",
    -o => "StrictHostKeyChecking=no"]);

1 个答案:

答案 0 :(得分:-1)

只需添加-F => ' somepath /配置'在master_opts下:

master_opts => [-F => ' somepath /配置']

和另一行如下:

$ self-> {ssh} - > {_ ssh_opts} = [' -F',' somepath / config'];'