Nouveau projet : user + git + ssh

useradd -m -s /bin/bash -d /home/center_git center_git
useradd -m -s /bin/bash -d /home/center_prod center_prod

su -l center_git -c "ssh-keygen -q -t rsa -N '' -f /home/center_git/.ssh/id_rsa"
su -l center_prod -c "ssh-keygen -q -t rsa -N '' -f /home/center_prod/.ssh/id_rsa"

echo "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAoBrnflaoJfcCETItWRL2TpFi4Fi3V1SzZxu7yLpuyR5RgTqp64HEAQJqTPxgD7vQpGAETjBByk7+8TyIQnFiWhWp30Gi9w6pxcfHpOR1PtwyyeTsKY7NiEl3zatA9fn2tNKOO0U6GsNIwvVTdyPDTltGpGsTnRSbvKtuCr+ok5Ns5iicgu2+Icqxavte0XM8GV9+V8v+XhmVJaGpkCUMwwzidw0cKc1BpZwDlOwZw7KMQ6BJVEdloBeyHjQm3QIxuMoqrhy+xeJeboc/4HDbnvlrLNs95EZAoEyNhm5oNsS0ujFkWbHB7Zrc/qdHre/fIPIIshPEB85myyXyLnOtkw== rsa-key-20120215-raf" >> /home/center_git/.ssh/authorized_keys
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAh3lDPLIg3/cjLOTsFC7S4Day5H4VkA2dBTb/LrsmPOb5/NJhSyq703p4kKM7mkzvB4gRJ0/YpH4iVbD9H39nDYOQqSokB9QfLyrRp0bgZqtt5R+jZ/YUPnu852yn+BLn1pn9+cn+ycuq9K35rbsXn9k7gVoG4AanwW/IeK8jGgU= rsa-key-20161116-martin" >> /home/center_git/.ssh/authorized_keys

echo "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAoBrnflaoJfcCETItWRL2TpFi4Fi3V1SzZxu7yLpuyR5RgTqp64HEAQJqTPxgD7vQpGAETjBByk7+8TyIQnFiWhWp30Gi9w6pxcfHpOR1PtwyyeTsKY7NiEl3zatA9fn2tNKOO0U6GsNIwvVTdyPDTltGpGsTnRSbvKtuCr+ok5Ns5iicgu2+Icqxavte0XM8GV9+V8v+XhmVJaGpkCUMwwzidw0cKc1BpZwDlOwZw7KMQ6BJVEdloBeyHjQm3QIxuMoqrhy+xeJeboc/4HDbnvlrLNs95EZAoEyNhm5oNsS0ujFkWbHB7Zrc/qdHre/fIPIIshPEB85myyXyLnOtkw== rsa-key-20120215-raf" >> /home/center_prod/.ssh/authorized_keys
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAh3lDPLIg3/cjLOTsFC7S4Day5H4VkA2dBTb/LrsmPOb5/NJhSyq703p4kKM7mkzvB4gRJ0/YpH4iVbD9H39nDYOQqSokB9QfLyrRp0bgZqtt5R+jZ/YUPnu852yn+BLn1pn9+cn+ycuq9K35rbsXn9k7gVoG4AanwW/IeK8jGgU= rsa-key-20161116-martin" >> /home/center_prod/.ssh/authorized_keys

echo 'center_git:XXXXXX' | chpasswd
echo 'center_prod:XXXXXX' | chpasswd

cat /home/center_prod/.ssh/id_rsa.pub >> /home/center_git/.ssh/authorized_keys

mkdir /home/center_git/git
git init --bare /home/center_git/git
chown -R center_git:center_git /home/center_git

su center_prod
mkdir /home/center_prod/site
cd
ssh-keyscan localhost >> /home/center_prod/.ssh/known_hosts
git clone center_git@localhost:/home/center_git/git /home/center_prod/site
git config --global user.email "rafi.piccolo@gmail.com"
git config --global user.name "prod"
git config --global push.default simple
exit
chown -R center_prod:center_prod /home/center_prod
chmod -R go-rwx /home/center_git;
chmod -R go-rwx /home/center_prod;

RENAME PROJECT
killall -u hopital_git
killall -u hopital_prod
usermod -l center_git hopital_git
usermod -l center_prod hopital_prod
emacs /etc/passwd
emacs /etc/group
mv /home/hopital_git /home/center_git
mv /home/hopital_prod /home/center_prod
chown -R center_git:center_git /home/center_git
chown -R center_prod:center_prod /home/center_prod
su center_prod
cd
cd site
emacs .git/config
git pull
exit
mv /var/spool/cron/crontabs/hopital_prod /var/spool/cron/crontabs/center_prod
emacs /var/spool/cron/crontabs/center_prod
emacs /etc/apache2/sites-enabled/000-default.conf
emacs /home/center_git/.ssh/authorized_keys
emacs /home/center_git/.ssh/id_rsa.pub
emacs /home/center_prod/.ssh/authorized_keys
emacs /home/center_prod/.ssh/id_rsa.pub

DELETE PROJECT
killall -u ooredoo_prod
userdel -f -r ooredoo_prod
emacs /etc/apache2/sites-enabled/000-default.conf

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.