Score:0

Group Creation Function

co flag

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

Klamber avatar
ru flag
Sorry, I don't quite get what you are asking for? Public key should be provided you by developers themselves. You should not generate it for them. Reason is that during transfer it could be compromised - in an e-mail, chat.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.