🛠 Piloter le Pi 2 en SSH et stabiliser son réseau
Objectives
Install and secure SSH access to the Raspberry Pi 2, understand its network specifics (10/100 Ethernet via the LAN9514 combo chip, no built-in WiFi), and fix the known issue on v1.2 boards: the random MAC address on every boot, which breaks DHCP leases and firewall rules.
Hardware
- Raspberry Pi 2 Model B (v1.2 to BCM2837: watch out for the MAC address issue)
- Ethernet cable to the box/router (no built-in WiFi or Bluetooth)
- A computer on the same network
Complete code
# 1. Activer SSH : sudo raspi-config -> Interface -> SSH -> Oui
# (sur l'image neuve : creer un fichier vide nomme ssh dans la partition boot)
sudo systemctl enable --now ssh
# 2. Recuperer l'adresse IP obtenue par DHCP
ip -4 addr show eth0 | grep inet
# 3. Cartes v1.2 : epingler une MAC fixe (sinon elle change a chaque boot)
MAC="b8:27:eb:12:34:56"
sudo sed -i "s/\s*rootwait/& smsc95xx.macaddr=${MAC}/" /boot/cmdline.txt
sudo reboot
# 4. Apres redemarrage : verifier puis se connecter depuis un autre poste
ip link show eth0 | grep ether
ssh pi@192.168.1.50
# 5. Debit maximal attendu (bus USB 2.0 partage, Ethernet 100 Mbps)
iperf3 -c 192.168.1.10
Expected verification
After activation, sshd is running (systemctl status ssh) and the connection succeeds from the other machine. After applying the macaddr fix, the same MAC address reappears on every reboot and the DHCP lease remains stable. iperf3 should approach 90 Mbit/s: this is the hardware limit of the 100 Mbps link and the shared USB bus, not a defect.
Common errors
- “Host key verification failed” after reflashing: remove the key from the client machine (
ssh-keygen -R 192.168.1.50). - IP address keeps changing: typical cause on v1.2 (random MAC) — apply the
smsc95xx.macaddrfix above. - Waiting for WiFi: the Pi 2 has neither WiFi nor Bluetooth; only a USB dongle adds wireless connectivity.
- Network slowness: the Ethernet port and the 4 USB ports share a single 480 Mbps bus; do not overload both.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython