공부
[linux] add user, user_su
승가비
2023. 4. 3. 14:35
728x90
user=seunggabi
passwd=****
rm ~/enable_id_pw.sh
cat <<EOT >> ~/enable_id_pw.sh
#!/bin/bash
sudo userdel -r ${user}
sudo adduser ${user}
echo "${user}:${passwd}" | sudo chpasswd
sudo userdel -r ${user}_su
sudo adduser ${user}_su
echo "${user}_su:${passwd}" | sudo chpasswd
sudo chmod u+w /etc/sudoers
sudo sed -i "/root\tALL=(ALL) \tALL/a${user}_su\tALL=(ALL) \tALL" /etc/sudoers
sudo chmod 440 /etc/sudoers
sudo sed -i 's/PasswordAuthentication no/#PasswordAuthentication no/' /etc/ssh/sshd_config
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo sed -i 's/ssh_pwauth: false/ssh_pwauth: true/' /etc/cloud/cloud.cfg
sudo sed -i 's/lock_passwd: true/lock_passwd: false/' /etc/cloud/cloud.cfg
sudo service sshd restart
EOT
chmod 755 ~/enable_id_pw.sh
sh ~/enable_id_pw.sh
rm ~/enable_id_pw.sh
https://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EA%B3%84%EC%A0%95_%EC%82%AD%EC%A0%9C_userdel
리눅스 계정 삭제 userdel - 제타위키
다음 문자열 포함...
zetawiki.com
728x90