mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 05:44:07 -07:00
Generate random root password instead of using admin password
This commit is contained in:
parent
3ed2cfa07b
commit
c32bd2c709
1 changed files with 5 additions and 6 deletions
|
@ -535,11 +535,11 @@ do
|
||||||
echo "--- New settings ---"
|
echo "--- New settings ---"
|
||||||
grep '^PermitRoot' /etc/ssh/sshd_config
|
grep '^PermitRoot' /etc/ssh/sshd_config
|
||||||
echo "--------------------"
|
echo "--------------------"
|
||||||
adminline=$(grep '^admin:' /etc/shadow)
|
root_password=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32)
|
||||||
adminline=${adminline:6}
|
hashed_root_password=$(openssl passwd -6 "$root_password")
|
||||||
adminline="root:$adminline"
|
sed -i "s#^root:.*#root:$hashed_root_password#" /etc/shadow
|
||||||
sed -i "s#^root:.*#$adminline#" /etc/shadow
|
echo "Root password is now a new random password."
|
||||||
echo "root password is now the same as admin password."
|
echo "New root password: $root_password"
|
||||||
echo "--------------------"
|
echo "--------------------"
|
||||||
grep '^root:' /etc/shadow
|
grep '^root:' /etc/shadow
|
||||||
grep '^admin:' /etc/shadow
|
grep '^admin:' /etc/shadow
|
||||||
|
@ -549,7 +549,6 @@ do
|
||||||
echo "--------------------"
|
echo "--------------------"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$answer" = 'r' ] || [ "$answer" = 'R' ]; then
|
if [ "$answer" = 'r' ] || [ "$answer" = 'R' ]; then
|
||||||
echo "============================="
|
echo "============================="
|
||||||
echo "== Rebooting the server"
|
echo "== Rebooting the server"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue