I have Created a Linux function that will create developers,
my requirement is to take the developer's first name and create a linux user and development environment. It should run something like the below commands:
adduser $1
usermod -a -G devs $1
mkdir /home/$1/.ssh
chmod 700 /home/$1/.ssh
touch /home/$1/.ssh/authorized_keys
chmod 600 /home/$1/.ssh/authorized_keys
mkdir /var/www/html/$1-dev.mysite.com/
mkdir /var/log/httpd/$1-dev.mysite.com/
chown $1.devs /var/www/html/$1-dev.mysite.com/
chown $1.devs /var/log/httpd/$1-dev.mysite.com/
If any of the '$1' directories exist it would throw a notice to the executor, right?
We'll need to edit the file created at step 6 after the process with the developer's key.. or do one of the options below would be better:
Pass the key in as a second parameter for function call
Create the key on the fly and output private key after function runs, and delete private key file?
I have tried this :
#!bin/bash
# sudo useradd -g devs username
# sudo usermod -a -G devs exampleusername
# mkdir -m 700 ${HOME}/.ssh
# touch $HOME/.ssh/authorized_keys
# chmod 600 ~/.ssh/authorized_keys
# cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
# sudo chown -R $USER:$USER /var/www/html/dev.mysite.com/
# sudo mkdir -p /var/log/dev.mysite.com/
# sudo chmod -R 744 /var/log/dev.mysite.com/
# sudo chown -R username /var/www/html/dev.mysite.com/
# sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /var/www/$dev.mysite.com
can anyone guide me on it!
I would be very grateful for any help, as my experience in this field is somewhat limited