Initial commit: VPS tutorial complet (105 etapes)
This commit is contained in:
210
02-config-base.md
Normal file
210
02-config-base.md
Normal file
@@ -0,0 +1,210 @@
|
||||
# 2. Configuration de Base
|
||||
|
||||
## Creer un utilisateur
|
||||
|
||||
```bash
|
||||
adduser <USER>
|
||||
usermod -a -G sudo <USER>
|
||||
```
|
||||
|
||||
## Configurer /etc/hosts
|
||||
|
||||
```bash
|
||||
cat > /etc/hosts << 'EOF'
|
||||
127.0.0.1 localhost
|
||||
127.0.1.1 <FQDN> <HOSTNAME>
|
||||
<IP> <FQDN> <HOSTNAME>
|
||||
|
||||
# IPv6
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
EOF
|
||||
```
|
||||
|
||||
## Verifier le hostname
|
||||
|
||||
```bash
|
||||
hostnamectl set-hostname <FQDN>
|
||||
hostname -f
|
||||
# Doit afficher : <FQDN>
|
||||
```
|
||||
|
||||
## Editeur par defaut
|
||||
|
||||
```bash
|
||||
apt install vim micro
|
||||
update-alternatives --config editor
|
||||
# Choisir micro ou vim
|
||||
```
|
||||
|
||||
## Installer etckeeper
|
||||
|
||||
```bash
|
||||
apt update && apt install etckeeper
|
||||
```
|
||||
|
||||
## Mettre a jour les sources apt
|
||||
|
||||
Ubuntu 24.04 utilise le format deb822 (`/etc/apt/sources.list.d/ubuntu.sources`).
|
||||
Verifier que `main universe restricted multiverse` et `backports` sont presents.
|
||||
|
||||
```bash
|
||||
apt update && apt dist-upgrade && apt autoremove
|
||||
```
|
||||
|
||||
## Paquets de base
|
||||
|
||||
```bash
|
||||
apt install curl wget ntpdate apt-transport-https apt-listchanges apt-file apt-rdepends man
|
||||
```
|
||||
|
||||
## Locale FR
|
||||
|
||||
```bash
|
||||
apt install locales
|
||||
dpkg-reconfigure locales
|
||||
# Selectionner fr_FR.UTF-8
|
||||
apt install task-french
|
||||
```
|
||||
|
||||
## Debfoster
|
||||
|
||||
```bash
|
||||
apt install debfoster
|
||||
debfoster
|
||||
```
|
||||
|
||||
### Script keeper pour etckeeper
|
||||
|
||||
Creer `/etc/etckeeper/pre-commit.d/35debfoster` :
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
set -e
|
||||
LANG=C
|
||||
export LANG
|
||||
|
||||
shellquote() {
|
||||
sed -e "s/'/'\"'\"'/g" -e "s/^/'/" -e "s/$/'/"
|
||||
}
|
||||
|
||||
if [ "$VCS" = git ] || [ "$VCS" = hg ] || [ "$VCS" = bzr ] || [ "$VCS" = darcs ]; then
|
||||
debfoster -q -k /etc/keepers
|
||||
chmod 600 /etc/keepers
|
||||
sed -i "1i\\# debfoster file" /etc/keepers
|
||||
sed -i "1i\\# Generated by etckeeper. Do not edit." /etc/keepers
|
||||
if [ "$VCS" = git ]; then
|
||||
git add keepers
|
||||
fi
|
||||
fi
|
||||
```
|
||||
|
||||
```bash
|
||||
chmod 755 /etc/etckeeper/pre-commit.d/35debfoster
|
||||
etckeeper commit
|
||||
```
|
||||
|
||||
## Mises a jour automatiques
|
||||
|
||||
```bash
|
||||
apt install unattended-upgrades
|
||||
```
|
||||
|
||||
## Interdire le login root SSH
|
||||
|
||||
```bash
|
||||
# Verifier dans /etc/ssh/sshd_config :
|
||||
PermitRootLogin no
|
||||
```
|
||||
|
||||
## Sudo sans mot de passe
|
||||
|
||||
```bash
|
||||
addgroup --system sudonp
|
||||
usermod -a -G sudonp <USER>
|
||||
echo '%sudonp ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/010_sudonp
|
||||
chmod 440 /etc/sudoers.d/010_sudonp
|
||||
```
|
||||
|
||||
> **Important :** Deconnectez-vous et reconnectez-vous pour activer le groupe.
|
||||
|
||||
## Neofetch + MOTD
|
||||
|
||||
```bash
|
||||
apt install neofetch
|
||||
```
|
||||
|
||||
Creer `/etc/neofetch.conf` :
|
||||
|
||||
```bash
|
||||
print_info() {
|
||||
info title
|
||||
info underline
|
||||
info "OS" distro
|
||||
info "Host" model
|
||||
info "Kernel" kernel
|
||||
info "Uptime" uptime
|
||||
info "Packages" packages
|
||||
info "Shell" shell
|
||||
info "CPU" cpu
|
||||
info "CPU Usage" cpu_usage
|
||||
prin "Load" "$(cat /proc/loadavg | awk '{print $1, $2, $3}')"
|
||||
info "GPU" gpu
|
||||
info "Memory" memory
|
||||
info "Disk" disk
|
||||
info "Local IP" local_ip
|
||||
info "Public IP" public_ip
|
||||
info "Users" users
|
||||
info "Locale" locale
|
||||
info cols
|
||||
}
|
||||
|
||||
title_fqdn="on"
|
||||
memory_percent="on"
|
||||
memory_unit="mib"
|
||||
package_managers="on"
|
||||
image_backend="ascii"
|
||||
cpu_temp="on"
|
||||
```
|
||||
|
||||
Creer `/etc/update-motd.d/20-neofetch` :
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
neofetch --config /etc/neofetch.conf
|
||||
```
|
||||
|
||||
```bash
|
||||
chmod 755 /etc/update-motd.d/20-neofetch
|
||||
```
|
||||
|
||||
## Script MOTD mises a jour
|
||||
|
||||
```bash
|
||||
apt install python3-apt
|
||||
```
|
||||
|
||||
Creer `/etc/update-motd.d/30-updates` avec le script Python de detection des mises a jour (voir scripts/setup_motd_updates.py).
|
||||
|
||||
```bash
|
||||
chmod 755 /etc/update-motd.d/30-updates
|
||||
```
|
||||
|
||||
## Installer dselect
|
||||
|
||||
```bash
|
||||
apt install dselect
|
||||
```
|
||||
|
||||
## Ajouter un fichier de swap (4 Go)
|
||||
|
||||
```bash
|
||||
fallocate -l 4G /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
swapon /swapfile
|
||||
echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
|
||||
echo 'vm.swappiness = 5' >> /etc/sysctl.conf
|
||||
sysctl -p
|
||||
```
|
||||
Reference in New Issue
Block a user