Starting to work on an initial FreePBX setup script
-
# Prompt for a username and password read -p "Enter a new username: " myUserName read -s -p "Enter a new password for $myUserName: " myPassword; echo # Prompt for your GitLab username read -p "Enter your GitLab username: " myGitLabUsername # Create user account and add user to wheel and asterisk group useradd --create-home $myUserName --password $myPassword gpasswd -a $myUserName wheel gpasswd -a $myUserName asterisk # Create .ssh directory, add authorized_keys file, set permissions mkdir /home/$myUserName/.ssh wget -O /home/$myUserName/.ssh/authorized_keys https://gitlab.com/$myGitLabUsername/public_keys/-/raw/master/authorized_keys chown -R $myUserName:$myUserName /home/$myUserName/.ssh chmod 700 /home/$myUserName/.ssh chmod 600 /home/$myUserName/.ssh/authorized_keys # Disable root login sed -i 's/#\?\(PerminRootLogin\s*\).*$/\1 no/' /etc/ssh/sshd_config # Disable PasswordAuthentication # Ends up with duplicate PasswordAuthentication because it modifies both #PasswordAuthentication and PasswordAuthentication sed -i 's/#\?\(PasswordAuthentication\s*\).*$/\1 no/' /etc/ssh/sshd_config wget https://raw.githubusercontent.com/sorvani/freepbx-helper-scripts/master/InitialSetup/setup.sh chmod +x setup.sh ./setup.sh systemctl restart sshd.service exit
-
@black3dynamite dunno if that is "better" from an automation standpoint, but it is certainly better from a guide standpoint.
-
so restoring again.
lots of typing from the initial root login in the Vultr virtual console. I need to make that less.
hmmm.... -
New method, testing now.
- Complete setup from ISO in Vultr Virtual Console.
- Log in as
root
user in the Vultr Virtual Console. - Download this script and execute.
wget https://raw.githubusercontent.com/sorvani/freepbx-helper-scripts/master/InitialSetup/root_setup.sh chmod +x root_setup.sh ./root_setup.sh
- Log in as your user via SSH
- Execute the
setup.sh
already in your home folder.
sudo ./setup.sh
-
Assuming this works as planned, then making it more generic would be next up.
For example, for getting the SSH public keys or not. -
That worked well.
-
@JaredBusch said in Starting to work on an initial FeePBX setup script:
@black3dynamite dunno if that is "better" from an automation standpoint, but it is certainly better from a guide standpoint.
Yeah, I was all over the place trying to make it more of an automation deployment.
One of the things going back and forth was the part for creating a password, I was thinking of using
chage -d 0 $myUserName
to force password change upon first login instead of having the user enter a password during the setup since the PasswordAuthentication is disabled. And then use arguments instead of read prompts. -
@black3dynamite said in Starting to work on an initial FeePBX setup script:
@JaredBusch said in Starting to work on an initial FeePBX setup script:
@black3dynamite dunno if that is "better" from an automation standpoint, but it is certainly better from a guide standpoint.
Yeah, I was all over the place trying to make it more of an automation deployment.
One of the things going back and forth was the part for creating a password, I was thinking of using
chage -d 0 $myUserName
to force password change upon first login instead of having the user enter a password during the setup since the PasswordAuthentication is disabled. And then use arguments instead of read prompts.I was thinking something like that also with the new user. But I had not had time to look up the syntax.
-
Corrected the title to FreePBX instead of FeePBX, lol. Although that name would be useful somewhere, too.
-
@scottalanmiller said in Starting to work on an initial FreePBX setup script:
Corrected the title to FreePBX instead of FeePBX, lol. Although that name would be useful somewhere, too.
go me