3 # Display options for a new or existing host config
5 require (-r 'sshd-lib.pl' ? './sshd-lib.pl' : './ssh-lib.pl');
8 &ui_print_header(undef, $text{'host_create'}, "", "chost");
11 &ui_print_header(undef, $text{'host_edit'}, "", "ehost");
12 $hconf = &get_client_config();
13 $host = $hconf->[$in{'idx'}];
14 $conf = $host->{'members'};
17 # Get version and type
18 if (&get_product_name() eq 'usermin') {
19 $version_type = &get_ssh_type();
20 $version_number = &get_ssh_version();
23 $version_type = $version{'type'};
24 $version_number = $version{'number'};
27 print &ui_form_start("save_host.cgi", "post");
28 print &ui_hidden("idx", $in{'idx'});
29 print &ui_hidden("new", $in{'new'});
30 print &ui_table_start($text{'host_header'}, "width=100%", 2);
33 print &ui_table_row($text{'host_name'},
34 &ui_opt_textbox("name", $host->{'values'}->[0] eq '*' ? '' :
35 $host->{'values'}->[0],
36 50, $text{'hosts_all'}));
38 # Default user to login as
39 $user = &find_value("User", $conf);
40 print &ui_table_row($text{'host_user'},
41 &ui_opt_textbox("user", $user, 20, $text{'host_user_def'}));
43 # Send keep-alive packets?
44 $keep = &find_value("KeepAlive", $conf);
45 print &ui_table_row($text{'host_keep'},
46 &yes_no_default_radio("keep", $keep));
48 # Real hostname to connect to
49 $hostname = &find_value("HostName", $conf);
50 print &ui_table_row($text{'host_hostname'},
51 &ui_opt_textbox("hostname", $hostname, 30, $text{'host_hostname_def'}));
54 $port = &find_value("Port", $conf);
55 print &ui_table_row($text{'host_port'},
56 &ui_opt_textbox("port", $port, 6, $text{'default'}." (22)"));
58 # Ask for password if needed, or fail fast?
59 $batch = &find_value("BatchMode", $conf);
60 print &ui_table_row($text{'host_batch'},
61 &yes_no_default_radio("batch", $batch));
64 $comp = &find_value("Compression", $conf);
65 print &ui_table_row($text{'host_comp'},
66 &yes_no_default_radio("comp", $comp));
68 # Escape character in session
69 $escape = &find_value("EscapeChar", $conf);
70 print &ui_table_row($text{'host_escape'},
71 &ui_radio("escape_def", $escape eq "" ? 1 :
72 $escape eq "none" ? 2 : 0,
73 [ [ 1, $text{'default'}." (~.)" ],
74 [ 2, $text{'host_escape_none'} ],
75 [ 0, &ui_textbox("escape",
76 $escape eq "none" ? "" : $escape, 4) ] ]));
78 if ($version_type ne 'ssh' || $version_number < 3) {
79 # SSH compression level
80 $clevel = &find_value("CompressionLevel", $conf);
81 print &ui_table_row($text{'host_clevel'},
82 &ui_radio("clevel_def", $clevel ? 0 : 1,
83 [ [ 1, $text{'default'} ],
84 [ 0, &ui_select("clevel", $clevel,
85 [ map { [ $_, $text{"host_clevel_".$_} ] }
88 # Number of times to attempt connection
89 $attempts = &find_value("ConnectionAttempts", $conf);
90 print &ui_table_row($text{'host_attempts'},
91 &ui_opt_textbox("attempts", $attempts, 5, $text{'default'}));
93 # Use local privileged port?
94 $priv = &find_value("UsePrivilegedPort", $conf);
95 print &ui_table_row($text{'host_priv'},
96 &yes_no_default_radio("priv", $priv));
98 # Try RSH if SSH fails?
99 $rsh = &find_value("FallBackToRsh", $conf);
100 print &ui_table_row($text{'host_rsh'},
101 &yes_no_default_radio("rsh", $rsh));
104 $usersh = &find_value("UseRsh", $conf);
105 print &ui_table_row($text{'host_usersh'},
106 &yes_no_default_radio("usersh", $usersh));
110 $agent = &find_value("ForwardAgent", $conf);
111 print &ui_table_row($text{'host_agent'},
112 &yes_no_default_radio('agent', $agent));
114 # Forward X connection?
115 $x11 = &find_value("ForwardX11", $conf);
116 print &ui_table_row($text{'host_x11'},
117 &yes_no_default_radio('x11', $x11));
119 # Strictly check host keys?
120 $strict = &find_value("StrictHostKeyChecking", $conf);
121 print &ui_table_row($text{'host_strict'},
122 &ui_radio('strict', lc($strict) eq 'no' ? 0 :
123 lc($strict) eq 'yes' ? 1 :
124 lc($strict) eq 'ask' ? 3 : 2,
125 [ [ 0, $text{'yes'} ], [ 1, $text{'no'} ],
126 [ 3, $text{'host_ask'} ], [ 2, $text{'default'} ] ]));
128 if ($version_type eq 'openssh') {
129 # Double-check remote host IP?
130 $checkip = &find_value("CheckHostIP", $conf);
131 print &ui_table_row($text{'host_checkip'},
132 &yes_no_default_radio('checkip', $checkip));
134 # SSH protocols to try
135 $prots = &find_value("Protocol", $conf);
136 print &ui_table_row($text{'host_prots'},
137 &ui_select("prots", $prots,
138 [ [ '', $text{'default'} ],
139 [ 1, $text{'host_prots1'} ],
140 [ 2, $text{'host_prots2'} ],
141 [ '1,2', $text{'host_prots12'} ],
142 [ '2,1', $text{'host_prots21'} ] ], 1, 0, 1));
145 print &ui_table_hr();
147 # Local ports to forward
148 @lforward = &find("LocalForward", $conf);
151 foreach $l (@lforward, { }) {
152 local ($lp, $rh, $rp) = ( $l->{'values'}->[0],
153 split(/:/, $l->{'values'}->[1]) );
154 push(@ltable, [ &ui_textbox("llport_$i", $lp, 8),
155 &ui_textbox("lrhost_$i", $rh, 8),
156 &ui_textbox("lrport_$i", $rp, 8) ]);
159 print &ui_table_row($text{'host_lforward'},
160 &ui_columns_table([ $text{'host_llport'}, $text{'host_lrhost'},
161 $text{'host_lrport'} ],
164 print &ui_table_hr();
166 # Remote ports to forward
167 @rforward = &find("RemoteForward", $conf);
170 foreach $r (@rforward, { }) {
171 local ($rp, $lh, $lp) = ( $r->{'values'}->[0],
172 split(/:/, $r->{'values'}->[1]) );
173 push(@rtable, [ &ui_textbox("rrport_$i", $rp, 8),
174 &ui_textbox("rlhost_$i", $lh, 40),
175 &ui_textbox("rlport_$i", $lp, 8) ]);
178 print &ui_table_row($text{'host_rforward'},
179 &ui_columns_table([ $text{'host_rrport'}, $text{'host_rlhost'},
180 $text{'host_rlport'} ],
183 print &ui_table_end();
185 print &ui_form_end([ [ undef, $text{'create'} ] ]);
188 print &ui_form_end([ [ undef, $text{'save'} ],
189 [ 'delete', $text{'delete'} ] ]);
192 &ui_print_footer("list_hosts.cgi", $text{'hosts_return'},
193 "", $text{'index_return'});