diff options
author | Antoine Ginies <aginies@mandriva.com> | 2005-06-08 01:17:48 +0000 |
---|---|---|
committer | Antoine Ginies <aginies@mandriva.com> | 2005-06-08 01:17:48 +0000 |
commit | 02e879ecc6d4d325bd83bbb453437f61a27fb01f (patch) | |
tree | 78addceb31aac0e3419440d700848a692998cfe9 /sshd_wizard/Sshd.pm | |
parent | e4ff9a22ec1a58c3e99f476360af9db2d03396a5 (diff) | |
download | drakwizard-02e879ecc6d4d325bd83bbb453437f61a27fb01f.tar drakwizard-02e879ecc6d4d325bd83bbb453437f61a27fb01f.tar.gz drakwizard-02e879ecc6d4d325bd83bbb453437f61a27fb01f.tar.bz2 drakwizard-02e879ecc6d4d325bd83bbb453437f61a27fb01f.tar.xz drakwizard-02e879ecc6d4d325bd83bbb453437f61a27fb01f.zip |
major update
Diffstat (limited to 'sshd_wizard/Sshd.pm')
-rwxr-xr-x | sshd_wizard/Sshd.pm | 207 |
1 files changed, 138 insertions, 69 deletions
diff --git a/sshd_wizard/Sshd.pm b/sshd_wizard/Sshd.pm index 42e0fa69..ab3d89a6 100755 --- a/sshd_wizard/Sshd.pm +++ b/sshd_wizard/Sshd.pm @@ -44,70 +44,148 @@ use Data::Dumper; print Dumper($sshd); my $o = { - name => 'Ssh wizard', + name => 'SSH wizard', var => { wiz_port => '', }, - init => sub { - test_host_domain($SHORTHOSTNAME, $DOMAINNAME); - }, +# init => sub { +# test_host_domain($SHORTHOSTNAME, $DOMAINNAME); +# }, needed_rpm => [ 'openssh-server' ], defaultimage => "/usr/share/wizards/sshd_wizard/images/sshd.png" }; my @yesorno = qw(yes no); push @yesorno, ""; +my @yesnoother = qw(yes no without-password forced-commands-only); push @yesnoother, ""; +my @syslog = qw(DAEMON USER AUTH LOCAL0 LOCAL1 LOCAL2 LOCAL3 LOCAL4 LOCAL5 LOCAL6 LOCAL7); push @syslog, ""; +my @loglevel = qw(QUIET FATAL ERROR INFO VERBOSE DEBUG DEBUG1 DEBUG2 DEBUG3); push @loglevel, ""; my %type = ( - 1 => N('Classical Ssh server'), - 2 => N('Permit Ssh login only with authorized_keys'), + 1 => N('Newbie - classical options'), + 2 => N('Expert - advanced ssh options'), ); $o->{pages} = { welcome => { - name => N('Ssh server configuration'), - post => sub { - if ($o->{var}{wiz_type} == 2) { - return 'via_auth' } - elsif ($o->{var}{wiz_type} == 1) { - return 'classical' } - }, + name => N('OpenSSH SSH daemon configuration'), data => [ - { label => N("Wich type of Ssh server do you you want:"), val => \$o->{var}{wiz_type}, list => [ keys %type ], format => sub { $type{$_[0]} } }, + { label => N("Wich type of configuration do you you want to do:"), val => \$o->{var}{wiz_type}, list => [ keys %type ], format => sub { $type{$_[0]} } }, ], + next => 'config_step1', }, - classical => { - name => N('Ssh server'), - pre => sub { - $sshd->{Protocol} and $o->{var}{wiz_protocol} = $sshd->{Protocol} or $o->{var}{wiz_protocol} = "2"; - }, - data => [ - { label => N('Protocol:'), fixed_val => \$o->{var}{wiz_protocol} }, - ], - next => 'config_step1', - }, config_step1 => { - name => N('Ssh server, classical options'), + name => N('SSH server, classical options'), pre => sub { - $sshd->{Port} and $o->{var}{wiz_port} = $sshd->{Port} or $o->{var}{wiz_port} = "22"; + $sshd->{ListenAddress} and $o->{var}{ListenAddress} = $sshd->{ListenAddress} or $o->{var}{ListenAddress} = "0.0.0.0"; + $sshd->{Port} and $o->{var}{Port} = $sshd->{Port} or $o->{var}{Port} = "22"; + $o->{var}{PermitRootLogin} ||= $sshd->{PermitRootLogin}; }, data => [ - { label => N('Port number:'), val => \$o->{var}{wiz_port}, help => N('Default port is 22.') }, + { label => N('Permit root login:'), val => \$o->{var}{PermitRootLogin}, fixed_list => \@yesnoother }, + { label => N('Listen address:'), val => \$o->{var}{ListenAddress}, help => N('Specifies the local addresses sshd should listen on.') }, + { label => N('Port number:'), val => \$o->{var}{Port}, help => N('Specifies the port number that sshd listens on. The default is 22.') }, ], complete => sub { - if ($o->{var}{wiz_port} !~ /^\d+$/) { $::in->ask_warn(N('Error'), N('Port should be a number')); return 1; } + if ($o->{var}{Port} !~ /^\d+$/) { $::in->ask_warn(N('Error'), N('Port should be a number')); return 1; } + }, + post => sub { + if ($o->{var}{wiz_type} == 2) { + return 'auth_options' } + elsif ($o->{var}{wiz_type} == 1) { + return 'summary' } }, - post => \&do_it, -# next => 'config_step2', - next => 'end', + next => 'auth_options', }, - config_step2 => { - next => 'config_step3', + auth_options => { + name => N('Authentication Method'), + pre => sub { + $o->{var}{RSAAuthentication} ||= $sshd->{RSAAuthentication}; + $o->{var}{PubkeyAuthentication} ||= $sshd->{PubkeyAuthentication}; + $sshd->{AuthorizedKeysFile} and $o->{var}{AuthorizedKeysFile} = $sshd->{AuthorizedKeysFile} or $o->{var}{AuthorizedKeysFile} = ".ssh/authorized_keys2"; + $o->{var}{PasswordAuthentication} ||= $sshd->{PasswordAuthentication}; + $o->{var}{IgnoreRhosts} ||= $sshd->{IgnoreRhosts}; + $o->{var}{PermitEmptyPasswords} ||= $sshd->{PermitEmptyPasswords}; + }, + data => [ + { label => N('RSA auth:'), val => \$o->{var}{RSAAuthentication}, fixed_list => \@yesorno }, + { label => N('PubKey auth:'), val => \$o->{var}{PubkeyAuthentication}, fixed_list => \@yesorno }, + { label => N('Auth key file:'), val => \$o->{var}{AuthorizedKeysFile} }, + { label => N('Password auth:'), val => \$o->{var}{PasswordAuthentication}, fixed_list => \@yesorno }, + { label => N('Ignore rhosts file:'), val => \$o->{var}{IgnoreRhosts}, fixed_list => \@yesorno }, + { label => N('Permit empty password:'), val => \$o->{var}{PermitEmptyPasswords}, fixed_list => \@yesorno }, + ], + next => 'log_options', }, - config_step3 => { - + log_options => { + name => N('Log') . "\n\n" . N('Syslog facility: gives the facility code that is used when logging messages from sshd') . "\n" . N('Log level: gives the verbosity level that is used when logging messages from sshd.'), + pre => sub { + $o->{var}{SyslogFacility} ||= $sshd->{SyslogFacility}; + $o->{var}{LogLevel} ||= $sshd->{LogLevel}; }, + data => [ + { label => N('Syslog facility:'), val => \$o->{var}{SyslogFacility}, fixed_list => \@syslog }, + { label => N('Log level:'), val => \$o->{var}{LogLevel}, fixed_list => \@loglevel }, + ], + next => 'login_options', + }, + login_options => { + name => N('Login options') . "\n\n" . N('Print last log: whether sshd should print the date and time when the user last logged in'), + pre => sub { + $o->{var}{LoginGraceTime} ||= $sshd->{LoginGraceTime}; + $o->{var}{KeepAlive} ||= $sshd->{KeepAlive}; + $o->{var}{PrintMotd} ||= $sshd->{PrintMotd}; + $o->{var}{PrintLastLog} ||= $sshd->{PrintLastLog}; + }, + data => [ + { label => N('Login Grace time:'), val => \$o->{var}{LoginGraceTime}, help => N('The server disconnects after this time if the user has not successfully logged in. If the value is 0, there is no time limit. The default is 120 seconds.') }, + { label => N('Keep alive:'), val => \$o->{var}{KeepAlive}, fixed_list => \@yesorno }, + { label => N('Print motd:'), val => \$o->{var}{PrintMotd}, fixed_list => \@yesorno }, + { label => N('Print last log:'), val => \$o->{var}{PrintLastLog}, fixed_list => \@yesorno }, + ], + complete => sub { + if ($o->{var}{LoginGraceTime} !~ /^\d+$/ and $o->{var}{LoginGraceTime}) { $::in->ask_warn(N('Error'), N('Login grace time should be a number')); return 1; } + }, + next => 'user_login', + }, + user_login => { + name => N('User Login options') . "\n\n" . N('Strict modes: specifies whether sshd should check file modes and ownership of the user\'s files and home directory before accepting login. This is normally desirable because novices sometimes accidentally leave their directory or files world-writable'), + pre => sub { + $o->{var}{StrictModes} ||= $sshd->{StrictModes}; + $o->{var}{AllowUsers} ||= $sshd->{AllowUsers}; + $o->{var}{DenyUsers} ||= $sshd->{DenyUsers}; + }, + data => [ + + { label => N('Strict modes:'), val => \$o->{var}{StrictModes}, fixed_list => \@yesorno }, + { label => N('Allow users:'), val => \$o->{var}{AllowUsers}, help => N('If specified, login is allowed only for user names that match one of the patterns. ie: erwan aginies guibo') }, + { label => N('Deny users:'), val => \$o->{var}{DenyUsers}, help => N('Login is disallowed for user names that match one of the patterns. ie: pirate guillomovitch') }, + ], + next => 'other', + }, + other => { + name => N('Compression: Specifies whether compression is allowed.') . "\n" . N('X11 forwarding: specifies whether X11 forwarding is permitted. Note that disabling X11 forwarding does not prevent users from forwarding X11 traffic, as users can always install their own forwarders.'), + pre => sub { + $o->{var}{Compression} ||= $sshd->{Compression}; + $o->{var}{X11Forwarding} ||= $sshd->{X11Forwarding}; + }, + data => [ + { label => N('Compression:'), val => \$o->{var}{Compression}, fixed_list => \@yesorno }, + { label => N('X11 forwarding:'), val => \$o->{var}{X11Forwarding}, fixed_list => \@yesorno }, + ], + next => 'summary', + }, + summary => { + name => N('Summary of OpenSSH configuration.'), + data => [ + { label => N('Permit root login:'), fixed_val => \$o->{var}{PermitRootLogin} }, + { label => N('Listen address:'), fixed_val => \$o->{var}{ListenAddress} }, + { label => N('Port number:'), fixed_val => \$o->{var}{Port} }, + ], + post => \&do_it, + next => 'end', + }, end => { - name => N('Congratulations') . "\n\n" . N('The wizard successfully configured your Ssh server.'), + name => N('Congratulations') . "\n\n" . N('The wizard successfully configured your SSH server.'), no_back => 1, end => 1, next => 0 @@ -135,50 +213,41 @@ sub write_conf_restart_ssh { } else { services::start('sshd') } } -sub auth_by_file() { -} - -sub global_config() { - $sshd->{Port} = $o->{var}{wiz_port}; +sub global_config { + $sshd->{Port} = $o->{var}{Port}; # force sshd protocol 2 - $sshd->{ListenAddress} and delete $sshd->{ListenAddress}; - $sshd->{Protocol} = "2"; -#ListenAddress 0.0.0.0 - - $sshd->{SyslogFacility} = "AUTH"; - $sshd->{LogLevel} = "INFO"; + $sshd->{Protocol} and $o->{var}{Protocol} = $sshd->{Protocol} or $o->{var}{Protocol} = "2"; + $o->{var}{ListenAddress} and $sshd->{ListenAddress} = $o->{var}{ListenAddress}; -#$sshd->{LoginGraceTime} 120 -#$sshd->{PermitRootLogin} no -#$sshd->{StrictModes} yes + $o->{var}{SyslogFacility} and $sshd->{SyslogFacility} = $o->{var}{SyslogFacility}; + $o->{var}{LogLevel} and $sshd->{LogLevel} = $o->{var}{LogLevel}; -#$sshd->{RSAAuthentication} yes -#$sshd->{PubkeyAuthentication} yes - $sshd->{AuthorizedKeysFile} = ".ssh/authorized_keys2"; -#$sshd->{PasswordAuthentication} no + $o->{var}{PermitRootLogin} and $sshd->{PermitRootLogin} = $o->{var}{PermitRootLogin}; + $o->{var}{StrictModes} and $sshd->{StrictModes} = $o->{var}{StrictModes}; + $o->{var}{AllowUsers} and $sshd->{AllowUsers} = $o->{var}{AllowUsers}; + $o->{var}{DenyUsers} and $sshd->{DenyUsers} = $o->{var}{DenyUsers}; -#$sshd->{RhostsAuthentication} no -#$sshd->{IgnoreRhosts} yes -#$sshd->{PermitEmptyPasswords} no -#$sshd->{KeepAlive} yes + $o->{var}{LoginGraceTime} and $sshd->{LoginGraceTime} = $o->{var}{LoginGraceTime}; + $o->{var}{KeepAlive} and $sshd->{KeepAlive} = $o->{var}{KeepAlive}; + $o->{var}{PrintMotd} and $sshd->{PrintMotd} = $o->{var}{PrintMotd}; + $o->{var}{PrintLastLog} and $sshd->{PrintLastLog} = $o->{var}{PrintLastLog}; - -#$sshd->{X11Forwarding} no -#$sshd->{PrintMotd} yes -#$sshd->{PrintLastLog} no -#$sshd->{Compression} yes + $o->{var}{RSAAuthentication} and $sshd->{RSAAuthentication} = $o->{var}{RSAAuthentication}; + $o->{var}{PubkeyAuthentication} and $sshd->{PubkeyAuthentication} = $o->{var}{PubkeyAuthentication}; + $o->{var}{AuthorizedKeysFile} and $sshd->{AuthorizedKeysFile} = $o->{var}{AuthorizedKeysFile}; + $o->{var}{PasswordAuthentication} and $sshd->{PasswordAuthentication} = $o->{var}{PasswordAuthentication}; + $o->{var}{IgnoreRhosts} and $sshd->{IgnoreRhosts} = $o->{var}{IgnoreRhosts}; + $o->{var}{PermitEmptyPasswords} and $sshd->{PermitEmptyPasswords} = $o->{var}{PermitEmptyPasswords}; + $o->{var}{X11Forwarding} and $sshd->{X11Forwarding} = $o->{var}{X11Forwarding}; + $o->{var}{Compression} and $sshd->{Compression} = $o->{var}{Compression}; #$sshd->{UsePrivilegeSeparation} yes - -#$sshd->{MaxStartups} 10 -#$sshd->{Subsystem} sftp /usr/libexec/sftp-server -#$sshd->{AllowUsers} } sub do_it { $::testing and return; # display a wait dialog box - my $in = 'interactive'->vnew('su', 'Ssh'); - my $w = $in->wait_message(N("Ssh server"), N("Configuring your Ssh server...")); + my $in = 'interactive'->vnew('su', 'SSH'); + my $w = $in->wait_message(N("OpenSSH server"), N("Configuring your OpenSSH server...")); global_config(); write_conf_restart_ssh(); # remove wait message |