UTF-404

su 에 λŒ€ν•΄ μ•Œμ•„λ³΄μž!!πŸ§‘πŸ»‍πŸ’» λ³Έλ¬Έ

λ¦¬λˆ…μŠ€

su 에 λŒ€ν•΄ μ•Œμ•„λ³΄μž!!πŸ§‘πŸ»‍πŸ’»

UTF-404 2024. 1. 27. 01:29
728x90

πŸ’‘ suλž€ ?

➑️ su(substitute user의 μ€„μž„λ§)λŠ” μœ λ‹‰μŠ€ λͺ…령을 λ‘œκ·Έμ•„μ›ƒν•˜μ§€ μ•Šκ³  λ‹€λ₯Έ μ‚¬μš©μžμ˜ κΆŒν•œμœΌλ‘œ 셸을 μ‹€ν–‰ν•˜λŠ”λ° μ‚¬μš©λœλ‹€. 일반적으둜 관리 μž‘μ—…μ„ μœ„ν•΄ λ‹€μ‹œ λ‘œκ·Έμ˜€ν”„ν•˜μ§€ μ•Šκ³  μ‚¬μš©μžμ˜ κΆŒν•œμ„ 루트둜 λ³€κ²½ν•˜λŠ”λ° μ‚¬μš©λœλ‹€. 같은 λ°©λ²•μœΌλ‘œ λ‹€λ₯Έ μ‚¬μš©μžλ‘œ μ „ν™˜ν•˜λŠ” 데 μ‚¬μš©λœλ‹€.

https://ko.wikipedia.org/wiki/Su_(%EC%9C%A0%EB%8B%89%EC%8A%A4)

 

su (μœ λ‹‰μŠ€) - μœ„ν‚€λ°±κ³Ό, 우리 λͺ¨λ‘μ˜ 백과사전

μœ„ν‚€λ°±κ³Ό, 우리 λͺ¨λ‘μ˜ 백과사전. su(substitute user[1]의 μ€„μž„λ§)λŠ” μœ λ‹‰μŠ€ λͺ…령을 λ‘œκ·Έμ•„μ›ƒν•˜μ§€ μ•Šκ³  λ‹€λ₯Έ μ‚¬μš©μžμ˜ κΆŒν•œμœΌλ‘œ 셸을 μ‹€ν–‰ν•˜λŠ” 데 μ‚¬μš©λœλ‹€. 일반적으둜 관리 μž‘μ—…μ„ μœ„ν•΄ λ‹€μ‹œ 둜그

ko.wikipedia.org

 

πŸ’‘ /su λͺ…λ Ή μ‚¬μš©λ°©λ²•!!

  1. 계정을 μ „ν™˜ν•˜κΈ° μœ„ν•΄μ„œ suλ₯Ό μ‹€ν–‰ν•œλ‹€.
  2. su λͺ…λ Ήμ˜ λŒ€μƒ 계정을 ν™•μΈν•˜κ³  νŒ¨μŠ€μ›Œλ“œλ₯Ό μž…λ ₯λ°›λŠ”λ‹€.
  3. μ‚¬μš©μžκ°€ μž…λ ₯ν•œ νŒ¨μŠ€μ›Œλ“œλ₯Ό /etc/shadow 와 비ꡐ해야 ν•œλ‹€.
  4. /etc/shadowλŠ” 000 νΌλ―Έμ…˜μ΄λ―€λ‘œ, rootκ°€ μ•„λ‹ˆλ©΄ μ—΄λžŒμ΄ λΆˆκ°€ν•˜λ‹€.
  5. λ”°λΌμ„œ, suλ₯Ό μ‹€ν–‰ν•˜λŠ”λ°μ—λŠ” λ¬Έμ œκ°€ 없어도 λΉ„λ°€λ²ˆν˜Έ 일치λ₯Ό 확인할 수 μ—†λ‹€.

πŸ“ su λ³΄μ•ˆ μ„€μ • 및 root 원격 접속 차단!!

[root@localhost ~]# useradd admin
[root@localhost ~]# usermod admin -G wheel
[root@localhost ~]# echo 1 | passwd --stdin admin
admin μ‚¬μš©μžμ˜ λΉ„λ°€ 번호 λ³€κ²½ 쀑
passwd: λͺ¨λ“  인증 토큰이 μ„±κ³΅μ μœΌλ‘œ μ—…λ°μ΄νŠΈ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
[root@localhost ~]# ls -l /bin/su
-rwsr-xr-x. 1 root root 34904 2016-05-11 17:59 /bin/su
[root@localhost ~]# chown .wheel /bin/su
[root@localhost ~]# chmod 4750 /bin/su
[root@localhost ~]# ls -l /bin/su
-rwsr-x---. 1 root wheel 34904 2016-05-11 17:59 /bin/su
[root@localhost ~]# vi /etc/ssh/sshd_config
[root@localhost ~]# cat -n /etc/ssh/sshd_config | grep 42
42 PermitRootLogin no
[root@localhost ~]# service sshd restart
sshd λ₯Ό μ •μ§€ 쀑: [ OK ]
sshd (을)λ₯Ό μ‹œμž‘ 쀑: [ OK ]

 

  1. su λͺ…λ Ήμ–΄λŠ” λŒ€μƒμ„ μ§€μ •ν•˜μ§€ μ•ŠμœΌλ©΄ root κ³„μ •μœΌλ‘œ μ „ν™˜μ„ μ‹œλ„ν•œλ‹€.
  2. su λͺ…λ Ήμ–΄λŠ” κ³„μ •λ§Œ μ „ν™˜ν•˜κ³ , ν™˜κ²½μš”μ†Œλ₯Ό λΆˆλŸ¬μ˜€μ§€ μ•ŠλŠ”λ‹€.
  3. su - 둜 μ‹€ν–‰ν•˜λ©΄ 계정을 μ „ν™˜ν•˜λ©΄μ„œ, λŒ€μƒ κΌμ •μ˜ ν™˜κ²½μš”μ†ŒκΉŒμ§€ λͺ¨λ‘ λΆˆλŸ¬μ˜¨λ‹€.

 

πŸ“ wheel κ·Έλ£Ή μ‚¬μš©μžμ—κ²Œ sudo λͺ…λ Ήμ–΄ ν—ˆμš©ν•˜κΈ°!!
➑️ sudo λŠ” 계정을 μ „ν™˜ν•˜μ§€ μ•Šκ³ μ„œλ„, κ΄€λ¦¬μž λͺ…령을 μ‹€ν–‰ν•  수 μžˆλ„λ‘ ν•œλ‹€.

root@localhost ~]# visudo
[root@localhost ~]# cat -n /etc/sudoers | head -101 | tail -5
97 ## Allows people in group wheel to run all commands
98 %wheel ALL=(ALL) ALL
99
100 ## Same thing without a password
101 %wheel ALL=(ALL) NOPASSWD: ALL
[root@localhost ~]#
[admin@localhost ~]$ sudo service network restart
μΈν„°νŽ˜μ΄μŠ€ eth0 (을)λ₯Ό μ’…λ£Œ 쀑: μž₯치 μƒνƒœ: 3 (μ—°κ²° 끊겼음)
[ OK ]
loopback μΈν„°νŽ˜μ΄μŠ€ μ’…λ£Œ 쀑: [ OK ]
loopback μΈν„°νŽ˜μ΄μŠ€ ν™œμ„±ν™”μ€‘ μž…λ‹ˆλ‹€: [ OK ]
eth0 μΈν„°νŽ˜μ΄μŠ€ ν™œμ„±ν™”μ€‘ μž…λ‹ˆλ‹€: ν™œμ„±ν™”λœ μ—°κ²° μƒνƒœ: ν™œμ„±ν™”λ¨
ν™œμ„±ν™”λœ μ—°κ²° 경둜: /org/freedesktop/NetworkManager/ActiveConnection/1
[ OK ]

 

πŸ“sudo μž‘μ—… μ΄ν›„, λͺ¨λ“  root κ³„μ •μ˜ μ ‘근을 μ°¨λ‹¨ (κΈ°λ³Έμ‰˜μ„ nologin으둜 λ³€κ²½)

[admin@localhost ~]$ usermod root -s /sbin/nologin
-bash: /usr/sbin/usermod: ν—ˆκ°€ κ±°λΆ€
[admin@localhost ~]$ sudo usermod root -s /sbin/nologin
[admin@localhost ~]$ cat /etc/passwd | head -1
root:x:0:0:root:/root:/sbin/nologin
[admin@localhost ~]$ su -
μ•”ν˜Έ:
This account is currently not available.
728x90