Added provision script
This commit is contained in:
		
							parent
							
								
									8c5343e342
								
							
						
					
					
						commit
						d9d5cc9ab1
					
				
							
								
								
									
										64
									
								
								server_provision.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								server_provision.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,64 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | echo "Starting Provision" | ||||||
|  | echo | ||||||
|  | ## Setup Admin user | ||||||
|  | function setup_user(){ | ||||||
|  | echo "Setup User Account" | ||||||
|  | echo | ||||||
|  | echo Choose Username:  | ||||||
|  | read username | ||||||
|  | sudo adduser $username  | ||||||
|  | sudo usermod -aG sudo $username | ||||||
|  | su $username | ||||||
|  | mkdir /home/$username/.ssh | ||||||
|  | touch /home/$username/.ssh/authorized_keys | ||||||
|  | } | ||||||
|  | setup_user; | ||||||
|  | 
 | ||||||
|  | ## Configure SSH Key | ||||||
|  | function ssh_pub_key(){ | ||||||
|  | echo "Configure SSH key for user" | ||||||
|  | echo | ||||||
|  | echo "Would you like to insert a ssh key for this user? (y / n) " | ||||||
|  | read yesorno | ||||||
|  | 
 | ||||||
|  | if [ "$yesorno" = y ]; then | ||||||
|  |     echo "Please paste the public key here: " | ||||||
|  |     read sshpubkey | ||||||
|  |     echo "$sshpubkey" >> /home/"$username"/.ssh/authorized_keys | ||||||
|  | 
 | ||||||
|  | elif [ "$yesorno" = n ]; then | ||||||
|  |     echo | ||||||
|  |     echo "______________!!WARNING!!_______________" | ||||||
|  |     echo "Yeah... thats not really an option." | ||||||
|  |     echo "Having password auth on a publicly facing" | ||||||
|  |     echo "SSH server on the internet is a bad idea" | ||||||
|  |     echo | ||||||
|  |     echo "________________________________________" | ||||||
|  |         | ||||||
|  |     ssh_pub_key; | ||||||
|  | else | ||||||
|  |     echo "Not a valid answer." | ||||||
|  |     ssh_pub_key; | ||||||
|  | fi | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ssh_pub_key; | ||||||
|  | 
 | ||||||
|  | ## Install software | ||||||
|  | sudo apt install apache2 ufw tmux  | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Setup Firewall | ||||||
|  | sudo ufw allow 22 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # Configure sshd | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user