Linux2011. 12. 25. 19:32
sudo는 일시적으로 root 권한을 받아와서 실행하는
setUID / setGUID 프로그램이고 정책(policy)의 일종이다.
즉, 이러한 권한 자체가 설정이 잘못되었을 경우 도용으로 인한 프로그램의 실행을 막을 방법은 없다는 것이다.
그런 이유로 커널수준에서 특정 권한을 막을 방법이 필요하게 되었고 이를 보완하기위해 만들어진 것이 selinux 이다.
라고는 하는데..

솔찍히 Fedora 쪽에서는 sudo의 주력 도입이 debian 보다는 늦은 편이었고
그로 인해서 초기에 sudo에 익숙해지는데 조금 불편함을 느꼈지만
반대로 Fedora에서는 초기에 selinux를 넣은데 반해 우분투에서는 기본 패키지로 추가하지 않아
Selinux를 끄거나 하는 불편함은 존재하지 않는걸 봐서는 미묘한 배포판의 컨셉의 차이라고 해야하나...



SUDO
sudo는 /etc/sudoers의 설정에 따라 움직인다.
wheel은 페도라에서 사용하는 그룹으로 우분투의 경우 admin 그룹을 지칭하고
wheel/admin은 말그대로 관리자 권한을 가지는 그룹을 의미한다. 


wheel 그룹에 대한 간단한 설명

그룹 (Wheel)

휠그룹은 무엇을 위한 것인가? 대부분 오랫동안 사용되어오면서 모호한 표현이라 생각한다. 이것은 사용자 권한을 나누기 위해 사용된다. root, 휠그룹, 그밖의 사용자로 3개의 계층으로 분류되어 있다. 

보통 휠그룹은 그에 속한 그룹 사용자들만 su root 를 사용할 수 있도록 하는 기능이다. FSF(자유소프트웨어 재단) 그룹은 이 원칙에 별로 따르지 않는데 왜냐하면 그것이 수학적 알고리즘이 아니기 때문이다. 

사용자를 최소로 구분하는 것은 sudo 에 의한다. 가장 많은 sudo 권한을 위한 자격으로 휠그룹 멤버쉽이라 불리는 것이 있다. 

역사적으로 말하면 그것은 초기 BSD중의 하나에서 시작되었다 생각한다. 

휠그룹을 만들므로써 휠의 기능을 쉽게 다시 만들 수 있으며 그리고 su 와 sudo (둘다 setuid 프로그램이다.)를 wheel 그룹으로 만들고 나서 다른 사용자에 대해서는 사용권한을 제거한다. 

  # chgrp wheel /bin/su /bin/sudo
  # chown o-rwx /bin/su /bin/sudo

물론 이것은 실제적으로 정상적인 사용자들에게 su와 sudo 를 사용할 수 없게 만든다. 문제는 서버에 어떤 정상적인 사용자들이 있는가이다. 
 
[링크 : http://zicman.egloos.com/2449683]  

sudoer 추가하기 

Fedora 
# visudo                       #  /etc/sudoers 파일이 열린다. `%wheel ALL=(ALL)` 라인 추가
# usermod -G wheel <userid>

Ubuntu 
# visudo                       #  /etc/sudoers 파일이 열린다. `%admin ALL=(ALL)` 라인 추가
# usermod -G admin <userid>
 
[링크 : http://wiki.kldp.org/wiki.php/sudo]  

The sudo philosophy
===================
Sudo is a program designed to allow a sysadmin to give limited root privileges
to users and log root activity.  The basic philosophy is to give as few
privileges as possible but still allow people to get their work done.

[링크 : http://www.sudo.ws/sudo/readme.html]  

[링크 : http://www.sudo.ws/sudo/sudoers.man.html]

SELINUX
SELinux에 대해서는 머만 하려고 하면 다 막혀서 항상 FC4 이후로는 항상 끄고 살았던 기억만.. OTL

[링크 : http://www.ibm.com/developerworks/kr/library/l-selinux/
[링크 : https://wiki.ubuntu.com/SELinux
    [링크 : http://packages.ubuntu.com/lucid/selinux-policy-ubuntu

2010/02/04 - [Linux/Ubuntu] - sudo 사용가능하도록 설정하기

'Linux' 카테고리의 다른 글

localtime() 과 mktime()을 이용하기  (0) 2012.03.27
partitionless disk  (2) 2012.01.06
조이스틱 / 조이패드 on ubuntu  (2) 2011.12.23
iptables MASQUERADE (공유기 만들기?)  (0) 2011.12.04
리눅스를 라우터로 만들기  (0) 2011.12.02
Posted by 구차니
Linux/Fedora Core2010. 3. 24. 15:34
sudo는 일시적으로 권한을 상승시켜 특정 프로그램을 실행하는 명령어이다.
그런데, FC6에서는 기본적으로 sudo를 사용하지 않고 있어서 추가를 해주어야 한다.


/etc/sudoers 는 설정파일로
## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
이 부분만 추가되어있다.
이 줄을 복사해서 root 대신 사용자 아이디를 넣어주면, 그 사용자는 모든 명령어에 대해 sudo로 실행할수 있게 된다.

예를 들어 dev라는 사용자를 추가하려면
dev    ALL=(ALL)       ALL
를 추가해주면 된다.


하지만, 이렇게만 하면 아래와 같은 문구가 나타난다.(lecture)
$ sudo ls

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password:

이녀석을 매번 보기 싫다면
Defaults    lecture = never
이 녀석을 한줄 추가해주면

ubuntu 처럼 깔끔하게
$ sudo ls
Password:
요렇게만 물어본다.

원래대로라면 직접 /etc/sudoers를 vi로 수정하지 말고
visudo 라는 vi를 이용하여 안전하게 수정을 해야 하지만, FC6에서는 없는듯 하다.

       lecture     This option controls when a short lecture will be printed along with the password prompt.
                   It has the following possible values:

                   never   Never lecture the user.
                   once    Only lecture the user the first time they run sudo.
                   always  Always lecture the user.

                   If no value is specified, a value of once is implied.  Negating the option results in a value of
                   never being used.  The default value is once.

       lecture_file
                   Path to a file containing an alternate sudo lecture that will be used in place of the standard lec-
                   ture if the named file exists.

[링크 : http://linux.die.net/man/5/sudoers]

[링크 : http://www.mjmwired.net/resources/mjm-fedora-fc6.html]
[링크 : http://ubuntuforums.org/archive/index.php/t-483591.html]
Posted by 구차니
Linux/Ubuntu2010. 2. 4. 21:20
우분투 데스크탑 버전만 쓰다보니, 여러 사용자의 권한을 생각해본적이 없다.
아무튼, 이런저런 이유로 인해 우분투에서 여러 사람이 쓰게 되었는데

역시나.. 초기추가하는 사용자는 기본적으로 sudo user로 추가가 된다.
간단하게 sudo 를 사용할수 있도록 하는 방법은 admin 그룹에 추가하는 것이다.

/etc/sudoers 에 WHEEL 이란건 먼지 좀 읽어봐야 할듯하다.

[링크 : http://zicman.egloos.com/2449683]
[링크 : http://wiki.kldp.org/wiki.php/sudo]

+
2019.10.28

아래의 명령을 이용하면 sudoer로 등록이 가능하다,.


Posted by 구차니
Linux2010. 2. 4. 20:58
sudo는 debian이던, fedora던 존재하지만,
아무튼, 일시적으로 root의 권한을 지니게하고 일반적으로 root의 행동은 log에 남지 않지만
sudo를 통해서 작업하면 로그로도 남기기 때문에 상대적으로 보안이 좀더 강화된다.

아무튼,
페도라에서는 su 로 root 쉘을 사용하지만
우분투에서는 sudo 로 일시적으로 상승시켜 명령을 실행한다.

물론 sudo -i 라는 명령을 이용해서 루트 쉘로 이동할수는 있다.
페도라의 su 명령어는 디렉토리가 변경되지 않는 반면,
우분투의 sudo -i 는 root의 홈 디렉토리(일반적으로 /root)로 이동한다.
sudo -isu - 와 동일한 느낌이다.

sudo -K | -L | -V | -h | -k | -l | -v
sudo [-HPSb] [-a auth_type] [-c class|-] [-p prompt] [-u username|#uid] {-e file [...] | -i | -s | command}

-i

The -i (simulate initial login) option runs the shell specified in the passwd(5) entry of the user that the command is being run as. The command name argument given to the shell begins with a - to tell the shell to run as a login shell. sudo attempts to change to that user's home directory before running the shell. It also initializes the environment, leaving TERM unchanged, setting HOME , SHELL , USER , LOGNAME , and PATH , and unsetting all other environment variables. Note that because the shell to use is determined before the sudoers file is parsed, a runas_default setting in sudoers will specify the user to run the shell as but will not affect which shell is actually run.

[링크 : http://linux.die.net/man/8/sudo]


기본 sudoers 파일 내용
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults    env_reset

# Uncomment to allow members of group sudo to not need a password
# %sudo ALL=NOPASSWD: ALL

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
 
[링크 : https://help.ubuntu.com/community/Sudoers]  

Posted by 구차니