레이블이 sudo인 게시물을 표시합니다. 모든 게시물 표시
레이블이 sudo인 게시물을 표시합니다. 모든 게시물 표시

2014년 12월 24일 수요일

CentOS에서 sudo 명령어 사용

CentOS는 일반사용자가 루트권한을 일시적으로 획득하는 sudo 명령어가 비활성 상태이다.
/etc/sudoers 파일을 수정하면 CentOS에서도 sudo를 이용할 수 있다.


[root@cet dev]$ ls -al /etc/sudoers
-r--r----- 1 root root 3381  3월 11  2014 /etc/sudoers

[root@cet dev]$ chmod u+w /etc/sudoers

[root@cet dev]$ ls -al /etc/sudoers
-rw-r----- 1 root root 3381  3월 11  2014 /etc/sudoers


[root@cet dev]# tail /etc/sudoers
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

## Allows members of the users group to mount and unmount the
## cdrom as root
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

/etc/sudoers 파일에 설정 추가

[root@cet ~]$ vi /etc/sudoers

# 특정 사용자가 sudo를 사용할 수 있도록 설정.
dev   ALL=(ALL)       ALL

# 그룹내에 모든 사용자가 이용할 수 있도록 설정.
%wheel  ALL=(ALL)       ALL

# 비밀번호 없이 사용
%wheel  ALL=(ALL)       NOPASSWD: ALL
dev   ALL=(ALL)       NOPASSWD: ALL

/etc/sudoers 파일의 퍼미션은 440이어야 하며 퍼미션 조정이 되어 있지 않으면 아래와 같은 에러가 발생.
[dev@cet ~]$ sudo tail /etc/sudoers
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting

root 계정으로 로그인 후 퍼미션 조정
[dev@cet ~]$ su -
[root@cet ~]# chmod u-w /etc/sudoers