What's new

Closed Delete all ssh user in a linux vps

Status
Not open for further replies.

Bon-chan

Forum Veteran
Joined
Mar 18, 2018
Posts
1,105
Reaction
4,854
Points
769
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
 
Last edited:
Debian:


CentOS:
boss yung delete all expired users sa database meron ba ?

auto delete yung mga na expire pero d ata na delete sa database kasi pag nag create ako ng same username dun sa na expire na.
Already Registered parin.
 
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.
Back
Top