%DIRECTIVES = ( BindAddress => [ \&_set_str, 'bind_address' ], Host => [ \&_host ], BatchMode => [ \&_batch_mode ], ChallengeResponseAuthentication => [ \&_set_yesno, 'auth_ch_res' ], Cipher => [ \&_cipher ], Ciphers => [ \&_set_str, 'ciphers' ], Compression => [ \&_set_yesno, 'compression' ], CompressionLevel => [ \&_set_str, 'compression_level' ], DSAAuthentication => [ \&_set_yesno, 'auth_dsa' ], GlobalKnownHostsFile => [ \&_set_str, 'global_known_hosts' ], HostKeyAlgorithms => [ \&_set_str, 'host_key_algorithms' ], HostName => [ \&_set_str, 'hostname' ], IdentityFile => [ \&_identity_file ], NumberOfPasswordPrompts => [ \&_set_str, 'number_of_password_prompts' ], PasswordAuthentication => [ \&_set_yesno, 'auth_password' ], PasswordPromptHost => [ \&_set_yesno, 'password_prompt_host' ], PasswordPromptLogin => [ \&_set_yesno, 'password_prompt_login' ], Port => [ \&_set_str, 'port' ], Protocol => [ \&_protocol ], RhostsAuthentication => [ \&_set_yesno, 'auth_rhosts' ], RhostsRSAAuthentication => [ \&_set_yesno, 'auth_rhosts_rsa' ], RSAAuthentication => [ \&_set_yesno, 'auth_rsa' ], UsePrivilegedPort => [ \&_set_yesno, 'privileged' ], User => [ \&_set_str, 'user' ], UserKnownHostsFile => [ \&_set_str, 'user_known_hosts' ], ); #### sub _create_socket { my $ssh = shift; my $sock = gensym; my ($p,$end,$delta) = (0,1,1); # normally we use whatever port we can get ($p,$end,$delta) = (1023,512,-1) if $ssh->{config}->get('privileged'); # allow an explicit bind address my $addr = $ssh->{config}->get('bind_address'); $addr = inet_aton($addr) if $addr; ($p,$end,$delta) = (10000,65535,1) if $addr and not $p; $addr ||= INADDR_ANY; for(; $p != $end; $p += $delta) { socket($sock, AF_INET, SOCK_STREAM, getprotobyname('tcp') || 0) || croak "Net::SSH: Can't create socket: $!"; last if not $p or bind($sock, sockaddr_in($p,$addr)); if ($! =~ /(Address|The socket name is) already in use/i) { close($sock); next; } croak "Net::SSH: Can't bind socket to port $p: $!"; } if($p) { $ssh->debug("Allocated local port $p."); $ssh->{config}->set('localport', $p); } $sock; } #### use Net::SSH::Perl; my %ssh_params = ( protocol => "2,1", identity_files => ["/home/codejerk/.ssh/test_id_dsa"], options => [ "BatchMode yes", "ConnectTimeout 3", "StrictHostKeyChecking no"], debug => 'true' );