Jump to content

Ubuntu-Client-on-Samba4-With-Policies

From TetraWiki


Ubuntu Client In Samba[edit]

# First login to ubuntu client as normal user 
###### First Stept to enable root login if it is ubuntu machine ################################################
sudo passwd root # it will promt you for user password from which you have login 
# Above command will set the password for the root user 
sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'
# Above will enable the GUI login of root user
# Now Login as root and install 2 Packages by below command
apt-get install likewise-open
apt-get install openssh-server
# After the Installation of the above two packages hit the below command to join the machine in the domain
domainjoin-cli join capitalbank.co.in administrator
# Above will Require a Restart of the machine 
# Now login as a domain user same as in window machine
# To leave the domain hist the below command
domainjoin-cli leave
# After Joining the client loing to the server and do the below 
# switch to root user login then hit the below command 
echo “10.0.0.229		usernameInitial” >> /etc/hosts
# Then the run below Script 
sh /scripts/open_login
# The above script contains
###############################################################################################################################
############################# This File is responsible to make newly added user to be login by server without password ########
username=`tail -n 1 /etc/hosts | awk '{print $2 }'`
ssh root@$username 'mkdir -p .ssh'
cat /root/.ssh/id_rsa.pub | ssh root@$username 'cat >> .ssh/authorized_keys'
ssh root@$username "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

###############################################################################################################################
sh /scripts/LDUPolicy 
# The above script contains
###########################################################################################################
######## This File Is responsible to add or update the user in linux ou in Samba4 for GPO #################
#!/bin/bash
defaulthomepath=home/likewise-open/CAPITALBANK
for username in `tail -n 1 /etc/hosts| awk '{print $2}'`
do 
echo "$username"
echo "Updating the wallpaper on user $username"
rsync -aP /home/userdoc/capital.jpg root@$username:/usr/share/backgrounds/capital.jpg && rsync -aP /scripts/.wallpaper root@$username:/$defaulthomepath/$username/  && echo "wallpaper updation done"
if [ `ssh root@$username "awk '/home/' /${defaulthomepath}/${username}/.profile | wc -l"` -eq 0 -o `ssh root@$username "awk '/home/' /${defaulthomepath}/${username}/.bashrc | wc -l"` -eq 0 ]
then
echo " Adding Profile"
echo " sh /$defaulthomepath/$username/.wallpaper " 
echo " sh /$defaulthomepath/$username/.wallpaper " | ssh root@$username "cat >> /${defaulthomepath}/${username}/.profile" && echo " sh /$defaulthomepath/$username/.wallpaper " | ssh root@$username "cat >> /${defaulthomepath}/${username}/.bashrc" && echo "Added profile succesfully "
else
echo " Already A member "
fi
echo "Policy getting updated to block control panel (system setting) in linux "
ssh root@$username "chmod 700 /usr/bin/gnome-control-center" && echo "updated system setting blocked for the normal user "
echo "Policy to restrict user to change there lan setting"
ssh root@$username  "chmod 700 /usr/bin/nm-connection-editor" && echo "Updated to restrict user to change there network setting for "
echo "folder redirection for linux users"
rsync -aP root@$username:/$defaulthomepath/$username/Documents/* /home/userdoc/$username/ ;chmod 744 /home/userdoc/$username/  && echo "Folder Redirection directory created and data transferd "
echo "Block user to open terminal"
ssh root@$username "chmod 700 /usr/bin/gnome-terminal" && echo "Users were blocked to open terminal"
echo "PROCESS SUCCESSFULLY COMPLITED FOR THE USER $username "
done
###########################################################################################################
# There is a crontab running for the folder redirection of all the linux user in every half hour which runs the script whit contains the below
#################################################################################################################
############### Responsible for user folder redirection #########################################################
#!/bin/bash
defaulthomepath=home/likewise-open/CAPITALBANK
for username in `cat /etc/hosts | (read; read; read; cat )| awk '{print $2}'`
do 
rsync -aP --delete root@$username:/$defaulthomepath/$username/Documents/* /home/userdoc/$username/
done
Note : We have Implement the only 5 policies which was required as project contract for linux machine but this is not the standard way to do so,
 but for doing it require High end Server to configure puppet (free but under development stage not yet stable properly ) or 
 centrify (paid tool for cross plateform policies management ).