Ubuntu Linux users may be familiar with using the “sudo” command in Linux. Ubuntu Linux užívatelia môžu byť oboznámení s pomocou "sudo" príkaz v Linuxe. It's a very useful feature in Linux that allows the administrator of a Linux machine to grant “root” privileges to a particular user or group of users. Je to veľmi užitočná funkcia, ktorá umožňuje v Linuxe správcu Linux stroj udeliť "root" oprávnenia konkrétneho užívateľa alebo skupiny užívateľov. It can also be configured so that this privilege is limited to one or more commands. Toto tiež môže byť nakonfigurovaný tak, aby toto oprávnenie je obmedzené na jeden alebo viacero príkazov. The Ubuntu team, for example, have decided to block the root user from logging in by default and instead allow users to use sudo to perform administrative tasks. Tím Ubuntu, napríklad, sa rozhodli blokovať užívateľa root od prihlásení do východiskové miesto a umožňujú používateľom sudo vykonávať administratívne úlohy. So if you are using Ubuntu Linux, sudo privileges have been setup so that you have full “root” privileges. Takže ak používate Ubuntu Linux, sudo privilégiá boli nastavení tak, že máte plnú "root" privilégiá. Let's take a closer look at setting up and configuring sudo privileges on your machine. Poďme sa bližšie pozrieť na nastavenie a konfiguráciu sudo oprávnenie na vašom počítači. Before proceeding please note that you should not try the following on a production server. Pred začatím prosím na vedomie, že by ste sa nemali vyskúšať nasledujúce na server. Please try out the examples in this tutorial on a test machine and get familiar with sudo before you try it out on a production server. Prosím, vyskúšať príklady v tomto tutoriálu na skúšobný stroj a zoznámte sa s sudo ako sa to vyskúšať na server. sudo is a very powerful tool and must be used with extreme caution. sudo je veľmi mocný nástroj a musí sa používať s extrémnou opatrnosťou.
To my knowledge the “sudo” package ships with all Linux distributions. Pokiaľ viem, "sudo" balík je dodávaný so všetkými linuxových distribúciach. So I'll skip the installation and jump straight to the configuration. Tak som si vynechať inštaláciu a prejsť priamo na konfiguráciu. For this tutorial I will use a Red Hat Linux machine. Z tohto tutoriálu budem používať Red Hat Linux stroj. Log into your Linux machine as root and run the following command on the command line: Prihláste sa do svojho stroja Linuxu ako root a zadajte nasledujúci príkaz na príkazovom riadku:
# visudo # Visudo
The above command will open the “sudo” configuration, which is at /etc/sudoers , using the default editor on your machine, which is Vim on mine. Vyššie uvedený príkaz Otvoriť "sudo" konfiguráciu, ktorá je v súbore / etc / sudoers, s použitím predvolený editor v počítači, ktorý je Vim o mne. Scroll down to the section where you see the following text: Prejdite nadol na časti, kde uvidíte nasledujúci text:
root ALL=(ALL) ALL root ALL = (ALL) ALL
The breakup of this sudo configuration syntax goes like this. Rozpadu tejto konfigurácii sudo syntax ide takhle. You first define the 'user' for which you want to setup sudo. Najskôr definovať 'user', pre ktorý chcete nastaviť sudo. Then comes the 'hostname' where the command is allowed to run. Potom príde 'hostname', kde je povolený príkaz na spustenie. This could be one specific hostname or “ALL” as in the example above. To by mohlo byť jedno konkrétne meno alebo "ALL" ako vo vyššie uvedenom príklade. And last is the 'command' for which you want to give the 'user' administrative privilege. A posledná je 'command', na ktorý chcete dať 'user' administratívne oprávnenie.
Back to the configuration. Späť na konfiguráciu. In Vim scroll down to the line shown above and hit the letter o on your keyboard to add a new line. V Vim nalistujte riadok je uvedené vyššie, a udreli o list na klávesnici pridať nový riadok. Now add the following text, replacing calvin with your own username: Teraz pridajte nasledujúci text, ktorý nahrádza calvin s vlastnou užívateľské meno:
calvin ALL=(ALL) ALL Calvin ALL = (ALL) ALL
Save and exit the file using the following key combination: Uložte a zatvorte súbor pomocou nasledujúce kombinácie klávesov:
ESC :wq ESC: wq
Hit the Return (enter) key to apply these instructions. Hit Return (vstup), kľúčom na uplatňovanie týchto usmernení. We have now given the user 'calvin' all administrative privileges using sudo. Máme teraz vzhľadom user 'Calvin' všetky administratívne oprávnenie používať sudo. Open a new terminal window and log in as the user that you granted sudo privileges to. Otvorte nové okno terminálu a prihláste sa ako používateľ, ktorý poskytuje sudo oprávnenie. Let's test whether the new permissions have been setup correctly by restarting the Apache web server as user 'calvin': Poďme si vyskúšať, či nové nastavenie oprávnenia boli správne reštartovať webový server Apache ako užívateľ 'Calvin':
# sudo /etc/init.d/httpd restart # Sudo / etc / init.d / httpd restart
Password: Heslo:
Stopping httpd: [ OK ] Zastavenie httpd: [OK]
Starting httpd: [ OK ] Štartovná httpd: [OK]
The system will now prompt you for a password. Systém bude teraz sa vás spýta na heslo. Enter the password for your username. Zadať heslo pre vaše užívateľské meno. And voila! A hľa! The Apache web server should now restart. Webový server Apache by teraz reštartovať. You can use this for any other administrative task. Môžete použiť pre akékoľvek ďalšie administratívne úlohy. Granting complete privileges to a user may not always be the best of ideas. Poskytnutie úplné oprávnenia užívateľov, nemusí byť vždy najlepšie nápady. So you can limit the user to a few command with administrative privileges. Takže sa môžete obmedziť používateľov na niekoľko príkaz s oprávneniami správcu. Let's say you want the user 'calvin' to be allowed to only restart the Apache web server. Povedzme, že chcete, aby sa používateľ 'Calvin', ktoré majú byť povolené iba reštartovať webový server Apache. Open the sudo configuration file using the visudo command and edit the line you entered earlier to look like this: Otvorte sudo konfiguračný súbor pomocou príkazu visudo a upravte riadok, ktoré ste zadali predtým vyzerať nasledovne:
calvin ALL=(ALL) /etc/init.d/httpd restart Calvin ALL = (ALL) / etc / init.d / httpd restart
Save and exit the file. Uložte a zatvorte súbor. Log into the terminal as the user 'calvin'. Prihláste sa do terminálu ako užívateľ 'Calvin'. Now try restarting Apache with sudo: Teraz skúste reštartovať Apache s sudo:
# sudo /etc/init.d/httpd restart # Sudo / etc / init.d / httpd restart
Password: Heslo:
Stopping httpd: [ OK ] Zastavenie httpd: [OK]
Starting httpd: [ OK ] Štartovná httpd: [OK]
Great. Veľký. It works. Funguje to. Now try stopping the web server: Teraz skúste zastaviť webový server:
# sudo /etc/init.d/httpd stop # Sudo / etc / init.d / httpd stop
Password: Heslo:
Sorry, user calvin is not allowed to execute '/etc/init.d/httpd stop' as root on commons. Ospravedlňujeme sa, užívateľ Calvin nie je dovolené execute '/ etc / init.d / httpd stop' ako root na commons.
So as you can see, the user 'calvin' can only do what we allow him to do, nothing more. Takže ako vidíte, môže používateľ 'Calvin' len to, čo sme mu umožňuje robiť, nič viac. You can add multiple commands in the sudoers file separated by commas. Môžete pridať viac príkazov v súbore sudoers oddelené čiarkami. So if you want to allow 'calvin' the permission to stop and restart the web server your configuration would read like this: Takže ak chcete povoliť 'Calvin' povolenie na zastavenie a reštarte webového servera konfigurácii by čítal takto:
calvin ALL=(ALL) /etc/init.d/httpd restart,/etc/init.d/httpd stop Calvin ALL = (ALL) / etc / init.d / httpd restart, / etc / init.d / httpd stop
Now try stopping the web server, and it should work: Teraz skúste zastaviť webový server, a malo by pracovať:
# sudo /etc/init.d/httpd stop # Sudo / etc / init.d / httpd stop
Password: Heslo:
Stopping httpd: [ OK ] Zastavenie httpd: [OK]
Another feature of sudo that is pretty useful, particularly if you need to perform an administrative task using a shell script, is setting the sudo privilege without being prompted for a password. Ďalším rysom sudo, že je celkom užitočné, najmä ak potrebujete urobiť správne činnosť pomocou skript, je nastavenie sudo privilégium, bez toho by bol vyzvaný na zadanie hesla. Remember that it may not be advisable to do this on a production machine using a username that is shared, because if the password for your username falls into the wrong hands it can spell trouble. Pamätajte si, že to nemusí byť vhodné, aby to na výrobnom stroji pomocou používateľského mena, ktoré je spoločné, pretože ak heslo pre meno dostane do nesprávnych rúk, môže kúzlo ťažkosti. So use this feature with caution. Takže použitie tejto funkcie so zvýšenou opatrnosťou.
Open the sudoers file and edit the line you entered earlier to look like this: Otvorte súbor sudoers a upravte riadok, ktoré ste zadali predtým vyzerať nasledovne:
calvin ALL=(ALL) /etc/init.d/httpd restart NOPASSWD: ALL Calvin ALL = (ALL) / etc / init.d / httpd restart NOPASSWD: ALL
The last part of the configuration instructs sudo to not prompt for or expect a password, and allow the user to execute the command that is assigned to it with administrative privileges. Posledná časť konfigurácia sudo pokyn, aby sa výzva na zadanie hesla alebo očakávate, a umožní vám spustiť príkaz, ktorý je priradený k nej s oprávneniami správcu. Save the file and exit from your text editor and try restart Apache: Uložte súbor a ukončite z vášho textového editora a skúste reštartovať Apache:
# sudo /etc/init.d/httpd restart # Sudo / etc / init.d / httpd restart
Stopping httpd: [ OK ] Zastavenie httpd: [OK]
Starting httpd: [ OK ] Štartovná httpd: [OK]
There is a lot more customization that can be done to the sudo configuration file. Existuje oveľa viac prispôsobenie, ktoré možno urobiť pre to sudo konfiguračný súbor. We have just looked at a small segment of it. Práve sme sa na malý segment to. However, this ought to give you a start. Však by to malo dať štart. Again, please use it with caution. Opäť, prosím, použite ju opatrne.























{ 2 trackbacks } Spätné (2)
{ 0 comments… (0 comments ... add one now pridať jednu teraz } )
Leave a Comment Zanechať komentár