🔒 Closed Delete all ssh user in a linux vps

Status
Not open for further replies.

Bon-chan

Forum Veteran
Debian:
while IFS=":" read -r users x uid x; do { [[ $uid -gt 1000 ]] && [[ $uid -lt 65534 ]]; } && userdel -r -f "$users"; done </etc/passwd

Centos:
while IFS=":" read -r users x uid x; do { [[ $uid -gt 500 ]] && [[ $uid -lt 65534 ]]; } && userdel -r -f "$users"; done </etc/passwd

Ty sa fix homer_simpson


Alternative way:
Changing user shell to /usr/sbin/nologin instead na iremove lahat ng user
by homer_simpson

Debian:
while IFS=":" read -r users x uid x; do { [[ $uid -ge 1000 ]] && [[ $uid -lt 65534 ]]; } && chsh -s /usr/sbin/nologin "$users"; done </etc/passwd

CentOS:
while IFS=":" read -r users x uid x; do { [[ $uid -ge 500 ]] && [[ $uid -lt 65534 ]]; } && chsh -s /usr/sbin/nologin "$users"; done </etc/passwd
 
boss paano ifix to after ko kasi irun yung script at nadelete yung mga users. gumawa ulit ako account para itest. pero ayaw na komonek. 3 server parapareho ayawna boss
 
Alternatively, pwede baguhin nalang login shell into /usr/sbin/nologin para ma-disable only instead of delete.

In-adjust ko ng konti yung one-liner: a) para hindi madamay sa modification yung 'nobody' account sa Debian which is quite an important account; b) greater than or equal to 1000 yung UID.

Code:
while IFS=":" read -r users x uid x; do { [[ $uid -ge 1000 ]] && [[ $uid -lt 65534 ]]; } && chsh -s /usr/sbin/nologin "$users"; done </etc/passwd
 
Alternatively, pwede baguhin nalang login shell into /usr/sbin/nologin para ma-disable only instead of delete.

In-adjust ko ng konti yung one-liner: a) para hindi madamay sa modification yung 'nobody' account sa Debian which is quite an important account; b) greater than or equal to 1000 yung UID.

Code:
while IFS=":" read -r users x uid x; do { [[ $uid -ge 1000 ]] && [[ $uid -lt 65534 ]]; } && chsh -s /usr/sbin/nologin "$users"; done </etc/passwd
boss, pano kung ang e delete ko yung mga expired users lang sa database ?
 
Alternatively, pwede baguhin nalang login shell into /usr/sbin/nologin para ma-disable only instead of delete.

In-adjust ko ng konti yung one-liner: a) para hindi madamay sa modification yung 'nobody' account sa Debian which is quite an important account; b) greater than or equal to 1000 yung UID.

Code:
while IFS=":" read -r users x uid x; do { [[ $uid -ge 1000 ]] && [[ $uid -lt 65534 ]]; } && chsh -s /usr/sbin/nologin "$users"; done </etc/passwd

ayhn dyan ngka prob kanina mga ovpn ko.

fix na to boss?
 
Isang option pa, use the lock method rather than change shell method. Either way will work. Pero mas preferred ko ito.

Code:
while IFS=":" read -r users x uid x; do { [[ $uid -ge 1000 ]] && [[ $uid -lt 65534 ]]; } && usermod -L "$users"; done </etc/passwd
[/code
 
Isang option pa, use the lock method rather than change shell method. Either way will work. Pero mas preferred ko ito.

Code:
while IFS=":" read -r users x uid x; do { [[ $uid -ge 1000 ]] && [[ $uid -lt 65534 ]]; } && usermod -L "$users"; done </etc/passwd
[/code
ano pinagkaiba nyan boss.? paglock pede pa ulit iunlock?
 
Isang option pa, use the lock method rather than change shell method. Either way will work. Pero mas preferred ko ito.

Code:
while IFS=":" read -r users x uid x; do { [[ $uid -ge 1000 ]] && [[ $uid -lt 65534 ]]; } && usermod -L "$users"; done </etc/passwd
[/code
boss homer,
may script ka dyan na delete expired users mismo sa database ?
 
Status
Not open for further replies.

About this Thread

  • 44
    Replies
  • 2K
    Views
  • 13
    Participants
Last reply from:
Reignman

Trending Topics

Online now

Members online
612
Guests online
613
Total visitors
1,225

Forum statistics

Threads
2,280,837
Posts
28,999,695
Members
1,226,013
Latest member
fardx
Back
Top