Ubuntu Suomen keskustelualueet
Ubuntun käyttö => Ubuntu tietokoneissa => Aiheen aloitti: Senior - 16.03.10 - klo:09.50
-
hakemistossa etc/security/ olevan tiedoston time.conf:n mukaan mm.seuraava rivi aikaansaisi sen että kaikkina päivinä käyttäjä jonka tunnus on "kayttaja" ei voisi klo 09.10-10.50 suorittaa koneella mitään toimintoja.
blank;tty* & !ttyp*;kayttaja;!Al0930-1050
Miten tuo toiminta ovat saatava käyttöön ja missä tiedostossa jotta asetukset astuisivat voimaan?
-
https://launchpad.net/timekpr/
tutustuppatuohon, voi olla on se ohjelma jota haet
http://forum.ubuntu-fi.org/index.php?topic=24827.0
täällä aikasempaa keskustelua ja pari kuvaakin
-
Tässä tarkempaa tietoa kyseisestä konffi tiedostosta.
http://articles.techrepublic.com.com/5100-10878_11-1055269.html
Tuo Jakke77 antama linkki ei suoraan koske tuohon tiedostoon.
-
mutta estää käyttäjän kirjautumisen koneelle tiettynä aikana
-
mutta estää käyttäjän kirjautumisen koneelle tiettynä aikana
Ajaa varmasti samaa asiaa, mutta ei tuon konffin kautta. Molemmat käyttävät kyllä PAM:ia. Nyt kysymyksessä oleva konffi on olemassa jo perusasennuksessa mukana ja käytössä. Riittää kunhan vain muokkaa tuota tiedostoa.
Mainitsemasi ohjelma tekee konffinsa toisaalle.
-
jätin ilman #-merkkiä eteen tuon lauseen:
blank;tty* & !ttyp*;kayttaja;!Al0930-1050
time.conf-tiedostoon ja sillä ei näyttänyt olevan mitään merkitystä.
samoin kokeilin buuttauksen jälkeen toimiiko esim.
http;tty1000;kayttaja;Al0600-11000
..ei toimi
"kayttaja":n tunniste on 1000. Liittyykö se tuohon tty1000:een???
-
en kyllä tiedä mikä minulla on väärin kirjoitettu tuossa time.conf-tiedostossa kun mitään tuollaisia rajoituksia ei näytä tule vaikka olen ohjeen mukaan yrittänyt tehdä. Mikä tuo tty on? Onko se käyttäjän kirjautumistunnus vai mikä?
tämäkin tuli kokeiltua - huonolla menestyksellä (koneen buuttauksen jälkeen, klo 12.12 loggautuminen onnistui vaikkei kai olisi pitänyt)
login & ssh;*;kayttaja;A10600-1200
-
Table A describes the function of each of these entries.
Table A Entry Function
services Used to list services used with PAM. Several records may be used with the same service.
ttys A list of devices that may be allowed or denied access.
users A list of users who are known to the system. This list may include root.
times A list which determines the times when a specific rule applies
-
Onko tuo time.conf-tiedosto sitten jollain käskyllä ajettava, jotta siihen tehdyt muutokset astuvat voimaan?
-
kokeile tuota timekpr ohjelmaa, saman asian ajaa ilman tiedostojen conffausta.
-
Taidanpa jättää asentamatta. Kun ei kerran pakettihallinnasta löydy jo suoraan sopivaa ohjelmaa niin saa minun puolesta olla.
It’s pretty rough right now ( just a couple of hours of research and bash hacking ) but it just kicked my son of the PC after his alloted hour and a half, so it’s functional – YMMV – I need to allow for different time limits on the weekends, and it uses a less than elegant method for shutting down gnome-session, so it’s very much a work in progress.
To install it, down load the script, timekpr , and rename it. Copy it someplace useful and make it executable:
mv timekpr.txt timekpr.sh
chmod 755 timekpr.sh
sudo mv timekpr.sh /usr/local/bin
Next make a directory for the time tracking files and limits:
sudo mkdir /var/lib/timekpr
I added a line to /etc/rc.local
/usr/local/bin/timekpr &
to start the script after a re-boot.
to limit someone’s per day usage, just add the number of seconds they will be allowed to a file in /var/lib/timekpr
sudo echo 7200 > /var/lib/timekpr/username
where username is the account you want to time limit.
I hope some parent finds this useful, my kids hate it already! (Heaven forbid they should go outside now and then…)
Tässä asiassa: pisteet Mandrivalle!! ::)
-
Onko tuo time.conf-tiedosto sitten jollain käskyllä ajettava, jotta siihen tehdyt muutokset astuvat voimaan?
Vaatii PAM palveluita.
-
Onko tuo time.conf-tiedosto sitten jollain käskyllä ajettava, jotta siihen tehdyt muutokset astuvat voimaan?
Vaatii PAM palveluita.
Ja tarkoittaa på finska? Mitä paketteja täytyy olla asennettuna?
Itsellä asennettu Python-pam, lib-pam modules + muutama muu PAM....
_t
Tässä on ilmeisesti kyse siitä mystisestä pam_time-moduulista. Missä lienee?
-
Tässä on ilmeisesti kyse siitä mystisestä pam_time-moduulista. Missä lienee?
Jep.
On vain melko sekaisen oloinen hässäkkä vähän kokeneemmallekin saatika sitten äkkinäiselle.
-
eli time.conf-tiedoston suora editointi ei siis saakaan aikaan mitään. En kyllä vieläkään tiedä mistä tuo pam_time-moduuli saadaan asennettua. Mitään tuon nimistä ei kyllä pakettihallinnasta löydy.
-
en kyllä tiedä mikä minulla on väärin kirjoitettu tuossa time.conf-tiedostossa kun mitään tuollaisia rajoituksia ei näytä tule vaikka olen ohjeen mukaan yrittänyt tehdä. Mikä tuo tty on? Onko se käyttäjän kirjautumistunnus vai mikä?
tämäkin tuli kokeiltua - huonolla menestyksellä (koneen buuttauksen jälkeen, klo 12.12 loggautuminen onnistui vaikkei kai olisi pitänyt)
login & ssh;*;kayttaja;A10600-1200
login & ssh;tty* & !ttyp*;käyttäjä;!Al0000-2400
oisko tuo rivi noin toimivampi. conffin esimerkki oli tälläinen.
#
# Here is a simple example: running blank on tty* (any ttyXXX device),
# the users 'you' and 'me' are denied service all of the time
#
#blank;tty* & !ttyp*;you|me;!Al0000-2400
-
login & ssh;tty* & !ttyp*;käyttäjä;!Al0000-2400
kokeiltu on eikä näytä toimivan... käyttäjä pääsee tunnuksellaan ja salasanalla järjestelmään..
-
kokeilenpa itse tuota timekrp:tä ja kerron miten vastaa
-
juu eli, tämä timekpr sallii koneen käytön tiettyinä aikoina, tietylle käyttäjälle. hieman aikaa meni että ymmärsin laittaa ajat oikein :) laitan kuvan malliksi, tässä sallitaan koneen käyttö kello 12:00:sta kello 06:00 aamuun. aamulla 06:00-12:00 ei pysty kirjautumaan koneelle.
jos ajat laittaisi toisin päin sallittaisiin kirjautuminen 06:00-12:00
[ylläpito on poistanut liitteen]
-
Tässä toimiva ohje.
http://skindley.wordpress.com/2006/12/11/fedora-core-6-controlling-logins-by-time/
Basic Restriction Example
The user we will use in this excercise is “jordan”.
As root edit /etc/security/time.conf and add
login|gdm;*;jordan;Al0800-1800
to the end of the file.
This line specifies that the console login and the graphical login are the affected services for the user named jordan on any tty on every day of the week from 8am until 6pm. There are other options for days of the week including excluding certain days while allowing others. You can read up on those option by reading the man time.conf manpage.
Next edit the /etc/pam.d/gdm file and add
account required pam_time.so
just below the auth entries.
Now edit /etc/pam.d/login file and add
account required pam_time.so
just below the auth entries there as well.
Thats it! Now the user “jordan” will only be able to login between 8AM and 6PM 7 days a week.
-
Eli on kokeiltu kahdella eri tavalla:
login & ssh;tty* & !ttyp*;kayttaja;!Al1800-0600
login & ssh;tty* & !ttyp*;kayttaja;!Al0600-1800
...buutattu kone....eikä mitään vaikeuksia päästä työasemaan klo 21
-
Eli on kokeiltu kahdella eri tavalla:
login & ssh;tty* & !ttyp*;kayttaja;!Al1800-0600
login & ssh;tty* & !ttyp*;kayttaja;!Al0600-1800
...buutattu kone....eikä mitään vaikeuksia päästä työasemaan klo 21
Muokkasitko myös tuossa ohjeessa mainittuja tiedostoja?
/etc/pam.d/gdm
/etc/pam.d/login
-
Kyllä laitoin ja nyt meni vähän liiankin hyvin. En enää päässyt ollenkaan järjestelmään. ::)
täytyy miettiä vielä noissa gdm- ja login-tiedostoissa että mihin kohtaan tarkalleen nuo rivit olisi laitettava.
"...just below the auth entries."
eli mihin "auth entries" päättyvät niin niiden alapuolelle siis rivit.
-
Tällaisilta näytti gdm-tiedosto:
#%PAM-1.0
auth requisite pam_nologin.so
auth required pam_env.so readenv=1
auth required pam_env.so readenv=1 envfile=/etc/default/locale
@include common-auth
auth optional pam_gnome_keyring.so
login & ssh;tty* & !ttyp*;kayttaja;!Al0830-2300
@include common-account
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
session required pam_limits.so
@include common-session
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
session optional pam_gnome_keyring.so auto_start
@include common-password
login-tiedosto:
#
# The PAM configuration file for the Shadow `login' service
#
# Enforce a minimal delay in case of failure (in microseconds).
# (Replaces the `FAIL_DELAY' setting from login.defs)
# Note that other modules may require another minimal delay. (for example,
# to disable any delay, you should add the nodelay option to pam_unix)
auth optional pam_faildelay.so delay=3000000
# Outputs an issue file prior to each login prompt (Replaces the
# ISSUE_FILE option from login.defs). Uncomment for use
# auth required pam_issue.so issue=/etc/issue
# Disallows root logins except on tty's listed in /etc/securetty
# (Replaces the `CONSOLE' setting from login.defs)
# Note that it is included as a "requisite" module. No password prompts will
# be displayed if this module fails to avoid having the root password
# transmitted on unsecure ttys.
# You can change it to a "required" module if you think it permits to
# guess valid user names of your system (invalid user names are considered
# as possibly being root).
auth requisite pam_securetty.so
# Disallows other than root logins when /etc/nologin exists
# (Replaces the `NOLOGINS_FILE' option from login.defs)
auth requisite pam_nologin.so
# SELinux needs to be the first session rule. This ensures that any
# lingering context has been cleared. Without out this it is possible
# that a module could execute code in the wrong domain.
# When the module is present, "required" would be sufficient (When SELinux
# is disabled, this returns success.)
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
# This module parses environment configuration file(s)
# and also allows you to use an extended config
# file /etc/security/pam_env.conf.
#
# parsing /etc/environment needs "readenv=1"
session required pam_env.so readenv=1
# locale variables are also kept into /etc/default/locale in etch
# reading this file *in addition to /etc/environment* does not hurt
session required pam_env.so readenv=1 envfile=/etc/default/locale
# Standard Un*x authentication.
@include common-auth
# This allows certain extra groups to be granted to a user
# based on things like time of day, tty, service, and user.
# Please edit /etc/security/group.conf to fit your needs
# (Replaces the `CONSOLE_GROUPS' option in login.defs)
auth optional pam_group.so
# Uncomment and edit /etc/security/time.conf if you need to set
# time restrainst on logins.
# (Replaces the `PORTTIME_CHECKS_ENAB' option from login.defs
# as well as /etc/porttime)
# account requisite pam_time.so
login & ssh;tty* & !ttyp*;kayttaja;!Al0830-2300
# Uncomment and edit /etc/security/access.conf if you need to
# set access limits.
# (Replaces /etc/login.access file)
# account required pam_access.so
# Sets up user limits according to /etc/security/limits.conf
# (Replaces the use of /etc/limits in old login)
session required pam_limits.so
# Prints the last login info upon succesful login
# (Replaces the `LASTLOG_ENAB' option from login.defs)
session optional pam_lastlog.so
# Prints the motd upon succesful login
# (Replaces the `MOTD_FILE' option in login.defs)
session optional pam_motd.so
# Prints the status of the user's mailbox upon succesful login
# (Replaces the `MAIL_CHECK_ENAB' option from login.defs).
#
# This also defines the MAIL environment variable
# However, userdel also needs MAIL_DIR and MAIL_FILE variables
# in /etc/login.defs to make sure that removing a user
# also removes the user's mail spool file.
# See comments in /etc/login.defs
session optional pam_mail.so standard
# Standard Un*x account and session
@include common-account
@include common-session
@include common-password
# SELinux needs to intervene at login time to ensure that the process
# starts in the proper default security context. Only sessions which are
# intended to run in the user's context should be run after this.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
# When the module is present, "required" would be sufficient (When SELinux
# is disabled, this returns success.)
..ja etc/security/time.conf-tiedosto
login & ssh;tty* & !ttyp*;kayttaja;!Al0830-2300
...jotain mäihää noissa
-
en ole conf asiantuntija mutta pitäiskö tämä muuttaa hieman
# This module parses environment configuration file(s)
# and also allows you to use an extended config
# file /etc/security/pam_env.conf.
#
muotoon:
# This module parses environment configuration file(s)
# and also allows you to use an extended config
file /etc/security/pam_env.conf.
#
ja ehkä:
# Uncomment and edit /etc/security/access.conf if you need to
# set access limits.
# (Replaces /etc/login.access file)
account required pam_access.so
-
en ole conf asiantuntija mutta pitäiskö tämä muuttaa hieman
# This module parses environment configuration file(s)
# and also allows you to use an extended config
# file /etc/security/pam_env.conf.
#
muotoon:
# This module parses environment configuration file(s)
# and also allows you to use an extended config
file /etc/security/pam_env.conf.
#
ja ehkä:
# Uncomment and edit /etc/security/access.conf if you need to
# set access limits.
# (Replaces /etc/login.access file)
account required pam_access.so
Tuossa ohjeessa on näin:
Next edit the /etc/pam.d/gdm file and add
account required pam_time.so
just below the auth entries.
Now edit /etc/pam.d/login file and add
account required pam_time.so
just below the auth entries there as well.
-
Nyt toimii. Eli laiton rivin
login|gdm;*;kayttaja;Al0800-1800
etc/security/time.conf-tiedostoon
ja sitten vain tiedostojen gdm ja login loppuosaan:
account required pam_time.so
No nyt jos haluaa esim. tehdä http:n käyttöön liittyviä aikarajoituksia, niin riittäneekö että koodia kirjoitetaan enää vain tuohon time.conf-tiedostoon vai täytyyköhän käydä jotain tiedostoa editoimassa myös etc/pam.d-hakemistossa? Tähänastinenhan on liittynyt järjestelmän tietyn käyttäjän loggautumisoikeuden aikarajoitukseen.
Pakollinen "ulosheitto" 15 minuutin armonajalla:
Esimerkki (Fedora)
Forced Logoff
If user jordan is logged in when 6PM comes around nothing will happen until she logs out. After she logs out she will not be permitted to log back in as per our PAM entries.
To setup a simple automatic logout procedure I will use a basic cron entry to force the logoff at a predetermined time. I will give a 15 minute “grace” period past the 6PM restriction.
As root I’ll enter crontab -e and edit the file to contain this line:
15 18 * * * /usr/bin/skill -KILL -u jordan
Now every day at 6:15PM the user “jordan” will be logged off forcefully without warning.
Make sure to restart the cron dameon with service crond restart after each cron change.