ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Starting to work on an initial FreePBX setup script

    IT Discussion
    freepbx scripting setup
    3
    13
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • black3dynamiteB
      black3dynamite
      last edited by black3dynamite

      # 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
      
      JaredBuschJ 1 Reply Last reply Reply Quote 2
      • JaredBuschJ
        JaredBusch @black3dynamite
        last edited by

        @black3dynamite dunno if that is "better" from an automation standpoint, but it is certainly better from a guide standpoint.

        black3dynamiteB 1 Reply Last reply Reply Quote 0
        • JaredBuschJ
          JaredBusch
          last edited by

          so restoring again.

          lots of typing from the initial root login in the Vultr virtual console. I need to make that less.
          hmmm....

          1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch
            last edited by JaredBusch

            New method, testing now.

            1. Complete setup from ISO in Vultr Virtual Console.
            2. Log in as root user in the Vultr Virtual Console.
            3. 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
            
            1. Log in as your user via SSH
            2. Execute the setup.sh already in your home folder.
            sudo ./setup.sh
            
            1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch
              last edited by

              Assuming this works as planned, then making it more generic would be next up.
              For example, for getting the SSH public keys or not.

              1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch
                last edited by JaredBusch

                That worked well.

                8900cd24-a391-4e02-89dc-d9ab8c633e8d-image.png
                c3a6a8b7-1c59-42a4-81f0-b8a24627da7d-image.png

                1 Reply Last reply Reply Quote 0
                • black3dynamiteB
                  black3dynamite @JaredBusch
                  last edited by

                  @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.

                  JaredBuschJ 1 Reply Last reply Reply Quote 0
                  • JaredBuschJ
                    JaredBusch @black3dynamite
                    last edited by

                    @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.

                    1 Reply Last reply Reply Quote 0
                    • scottalanmillerS
                      scottalanmiller
                      last edited by

                      Corrected the title to FreePBX instead of FeePBX, lol. Although that name would be useful somewhere, too.

                      JaredBuschJ 1 Reply Last reply Reply Quote 0
                      • JaredBuschJ
                        JaredBusch @scottalanmiller
                        last edited by

                        @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

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post