/bash-aws-vhost-automation

Bash script for Amazon Linux AMI that automatically creates vhost.conf file from user input in the terminal. Automates a common task, reduces the need to edit files, reduces key strokes.

Primary LanguageShellGNU General Public License v2.0GPL-2.0

bash-aws-web-hosting-automation

Bash script for Amazon Linux AMI that automatically sets up webhosting (based on user input in the terminal) as follows:

New virtual hosts by creating new nodes in the config file
New SFTP user and website document root (in ~user/public_html)
SSH keypair for new user
Chrooted SFTP home directory (~user)

Automates common tasks, reduces the need to edit files, reduces key strokes.

Assumptions

Using Amazon Linux AMI
Installed httpd24 through yum
Updated default home directory permissions to 755 (in /etc/login.defs)
Modified sftp subsystem in /etc/ssh/sshd_config to internal-sftp

Installation

begin with: /usr/bin/make-vhost sudo chmod 755 /usr/bin/make-vhost sudo /usr/bin/make-vhost

How It Works

Scripts checks for root access and presence of httpd 2.4 (installed through yum/rpm) Script prompts for domain name and username for the new site
Script checks /etc/httpd/conf.d to see if vhost.conf exists (creates it if not)
New user is created, along with public_html document root under their home directory
A new node is appended to end of vhost.conf
A new block is appended to the end of sshd_config (for chrooted sftp)
SSH keypair is generated for new user and ec2-user's authorized_keys are copied to new user (optionally, private key printed to screen for local copy/paste, if desired)
Script prompts for httpd and sshd reload
Summary of operations is displayed