-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·48 lines (48 loc) · 1.7 KB
/
script.sh
File metadata and controls
executable file
·48 lines (48 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
echo "Changement du mot de passe :"
passwd
apt-get update
apt-get upgrade -y
apt-get install fail2ban -y
echo "Nom d'utilisateur à ajouter :"
read user
useradd -m -d /home/$user -s /bin/bash $user
passwd $user
mkdir /home/$user
mkdir /home/$user/.ssh
chmod 700 /home/$user/.ssh
test=0
while [ $test = 0 ]
do
echo "Clee ssh :"
read key
echo $key >> /home/$user/.ssh/authorized_keys
echo "........................................."
cat /home/$user/.ssh/authorized_keys
echo "........................................."
echo "ok?(0=non)"
read test
done
chmod 400 /home/$user/.ssh/authorized_keys
chown $user:$user /home/$user -R
echo ".........................................
Ajouter '$user ALL=(ALL) ALL' sous 'root ALL=(ALL) ALL'
(fonctionnement de vi: 'i' pour editer 'echap : x' pour enregistrer et quitter)
........................................."
read ok
visudo
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
service ssh restart
apt-get install unattended-upgrades -y
echo "APT::Periodic::Update-Package-Lists "1";" >> /etc/apt/apt.conf.d/10periodic
echo "APT::Periodic::Download-Upgradeable-Packages "1";" >> /etc/apt/apt.conf.d/10periodic
echo "APT::Periodic::AutocleanInterval "7";" >> /etc/apt/apt.conf.d/10periodic
echo "APT::Periodic::Unattended-Upgrade "1";" >> /etc/apt/apt.conf.d/10periodic
apt-get install logwatch -y
echo "Email pour logwatch :"
read mail
echo "'daily' pour un rapport journalier, 'weekly' hebdomadaire ou 'monthly' mensuel (sans ') :"
read frequence
echo "#!/bin/bash
test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0
/usr/sbin/logwatch --output mail --mailto $mail --detail high" > /etc/cron.$frequence/00logwatch