update : not good
This commit is contained in:
98
-01-ssh/script.sh
Normal file
98
-01-ssh/script.sh
Normal file
@@ -0,0 +1,98 @@
|
||||
#!/bin/sh
|
||||
# Pour la configuration du ssh
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NOCOLOR='\033[0m'
|
||||
|
||||
echo "${YELLOW} ** ${NOCOLOR} Début du script : 01-ssh"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Controle des persmissions"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
check_permissions
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Controle des persmissions : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Controle des pre requis"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
check_requirements
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Controle des pre requis : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Sauvegarde ancien fichiers"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
backup_files
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Sauvegarde ancien fichiers : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Update du systeme"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
update_system
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Update du systeme : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Copie du fichier : authorized_keys"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
cp 01-ssh/authorized_keys /root/.ssh/authorized_keys >> /dev/null
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Copie du fichier : authorized_keys : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Copie des fichiers : ssh"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
cp 01-ssh/ssh_config /etc/ssh/ssh_config >> /dev/null
|
||||
cp 01-ssh/sshd_config /etc/ssh/sshd_config >> /dev/null
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Copie des fichiers : ssh : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Copie du fichier : banner"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
cp 01-ssh/banner /etc/banner >> /dev/null
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Copie du fichier : banner : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Copie du fichier : 00-basic"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
cp 01-ssh/00-basic /etc/update-motd.d/00-basic >> /dev/null
|
||||
chmod +x /etc/update-motd.d/00-basic >> /dev/null
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Copie du fichier : 00-basic : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Création du lien synbolique"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
mkdir -p /etc/ssh/authorized_keys/ >> /dev/null
|
||||
|
||||
cd /etc/ssh/authorized_keys/ >> /dev/null
|
||||
|
||||
ln -s /root/.ssh/authorized_keys root >> /dev/null
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Création du lien synbolique : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Relance du service sshd"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
systemctl restart sshd >> /dev/null
|
||||
|
||||
echo "${YELLOW} * ${NOCOLOR} Relance du service sshd : ${GREEN} OK"
|
||||
echo "${NOCOLOR}"
|
||||
|
||||
echo "${YELLOW} ** ${NOCOLOR} Fin du script : 01-ssh"
|
||||
echo "${NOCOLOR}"
|
||||
Reference in New Issue
Block a user