I) Utilisateurs. 1) Ajouter l'utilisateur root :
/ # echo "root:0:0:root:/root:/sbin/sh" > /etc/passwd
/ # echo "root:x:0:" > /etc/group
2) Changer le mot de passe
/ # passwd
3) Ajouter un utilisateur normal :
/ # adduser rpi
4) Vérification :
/ # ls -l /home
root@RaspberryPi [/root]# ls -l /home
total 8
drwxr-sr-x 2 rpi rpi 4096 Jan 1 00:05 rpi
/ # cat /etc/passwd
root:a1U/7iVM41kGs:0:0:root:/root:/bin/sh
rpi:gCvrT9cfEydko:1000:1000:Linux User,,,:/home/rpi:/bin/sh
II) Configuration du login :
/etc/inittab
Remplacer tout par :
::sysinit:/etc/init.d/rcS
tty1::respawn:/sbin/getty 0 /dev/tty1
tty2::respawn:/sbin/getty 0 /dev/tty2
tty3::respawn:/sbin/getty 0 /dev/tty3
tty4::respawn:/sbin/getty 0 /dev/tty4
ttyAMA0::respawn:/sbin/getty 115200 /dev/ttyAMA0
/etc/hostname
Ajouter :
RaspberryPi
/etc/init.d/rcS
Ajouter :
hostname -F /etc/hostname
/etc/profile
Ajouter :
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
PS1="\u@\h [\W]"
if [ $(id -u) -eq 0 ]
then
PS1=${PS1}"# "
else
PS1=${PS1}"$ "
fi
II) Réseau :
/etc/resolv.conf
Ajouter :
nameserver 80.10.246.2
Ouvrir :
/etc/init.d/rcS
Ajouter :
/etc/init.d/rc.network &
Ouvrir :
/etc/init.d/rc.network
Ajouter :
#!/bin/sh
/sbin/ifconfig lo 127.0.0.1
while ! /sbin/ifconfig -a | grep eth0 >/dev/null
do
sleep 1
done
/bin/ifplugd -i eth0
chmod 777 /etc/init.d/rc.network
Ouvrir :
/etc/ifplugd/ifplugd.action-statique
Ajouter :
#!/bin/sh
if [ "$1" = "eth0" ] ; then
IP_HOST=192.168.1.11
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
IP_DNS=80.10.246.2
if [ "$2" = "up" ] ; then
/sbin/ifconfig eth0 ${IP_HOST} netmask ${NETMASK}
if [ "${GATEWAY}" != "" ] ; then
/sbin/route add default gw "${GATEWAY}"
fi
if [ "${IP_DNS}" != "" ] ; then
echo "nameserver ${IP_DNS}" > /etc/resolv.conf
fi
fi
fi
return 0
Action :
/etc/ifplugd/ # ln -s ifplugd.action-statique ifplugd.action
/etc/ifplugd/ # chmod 777 ./ifplugd.action*
root@RaspberryPi [/root]# ifconfig eth0 192.168.1.11 netmask 255.255.255.0
root@RaspberryPi [/root]# route add default gw 192.168.1.1
[~] ➔ ping 192.168.1.11 -c 3
PING 192.168.1.11 (192.168.1.11) 56(84) bytes of data.
64 bytes from 192.168.1.11: icmp_req=1 ttl=64 time=0.470 ms
64 bytes from 192.168.1.11: icmp_req=2 ttl=64 time=0.489 ms
64 bytes from 192.168.1.11: icmp_req=3 ttl=64 time=0.567 ms
--- 192.168.1.11 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.470/0.508/0.567/0.049 ms
root@RaspberryPi [/root]# ifconfig
eth0 Link encap:Ethernet HWaddr B8:27:EB:E7:1A:95
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:fee7:1a95/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:323 errors:0 dropped:0 overruns:0 frame:0
TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:29034 (28.3 KiB) TX bytes:24800 (24.2 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
root@RaspberryPi [/root]# ping 192.168.1.1 -c 3
root@RaspberryPi [/root]# ping google.fr
III) Service d'un serveur internet :
/etc/init.d/rcS
Ajouter :
/etc/init.d/rc.services &
Ouvrir :
/etc/init.d/rc.services
Ajouter :
#!/bin/sh
/sbin/telnetd
/sbin/httpd -h /home/httpd
root@RaspberryPi [/root]# /sbin/httpd -h /home/httpd
/home/httpd/index.html
Ajouter :
<html>
<head>
<title>Raspberry Pi from scratch</title>
</head>
<body>
Cette page s'affiche depuis un petit serveur http embarqué sur mon Raspberry Pi.****
Action :
root@RaspberryPi [/root]# httpd -h /home/httpd
/root/arreter.sh
Ajouter :
#!/bin/sh
mount / -o ro,remount
halt
V) Accés sécurisé : 1) Compilation de dropbear : A partir de l'ordinateur de développement :
[~] ➔ cd RaspberryPi/
[~/RaspberryPi] ➔ wget https://matt.ucc.asn.au/dropbear/releases/dropbear-2012.55.tar.gz
[~/RaspberryPi] ➔ tar xvfz dropbear-2012.55.tar.gz
[~/RaspberryPi] ➔ cd dropbear-2012.55/
[~/RaspberryPi/dropbear-2012.55] ➔ PATH=$PATH:/usr/local/cross-rpi/usr/bin/
[~/RaspberryPi/dropbear-2012.55] ➔ ./configure --host=arm-linux --disable-zlib
[~/RaspberryPi/dropbear-2012.55] ➔ make
[~/RaspberryPi/dropbear-2012.55] ➔ make scp
[~/RaspberryPi/dropbear-2012.55] ➔ sudo scp dropbear dropbearkey scp /media/Root/usr/bin/
A partir du RPi : Ouvrir :
/etc/init.d/rc.services
Ajouter :
if[! -f /etc/dropbearkey.rsa]; then
/usr/bin/dropbearkey -t rsa -f /etc/dropbearkey.rsa
fi
/usr/bin/dropbear -r /etc/dropbearkey.rsa
[~] ➔ ssh root@192.168.1.11
The authenticity of host '192.168.1.11 (192.168.1.11)' can't be established.
RSA key fingerprint is 7c:e8:9b:f4:9c:ba:31:a0:1a:a5:40:b3:4a:84:93:92.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.11' (RSA) to the list of known hosts.
root@192.168.1.11's password:
root@RaspberryPi [/root]#
Erreur :
[~] ➔ ssh root@192.168.1.11
root@192.168.1.11's password:
PTY allocation request failed on channel 0
shell request failed on channel 0
Solution :
root@RaspberryPi [/root]# mkdir /dev/pts
root@RaspberryPi [/root]# echo "none /dev/pts devpts defaults 0 0" >> /etc/fstab
root@RaspberryPi [/root]# mount /dev/pts
VI) Script d'initialisation du réseau et des services réseaux. Ouvrir :
/root/reseau.sh
Ajouter :
#!/bin/sh
ifconfig eth0 192.168.1.11 netmask 255.255.255.0
route add default gw 192.168.1.1
sleep 3
/sbin/telnetd
/sbin/httpd -h /home/httpd
/usr/bin/dropbear -r /etc/dropbearkey.rsa
mkdir /dev/pts
mount /dev/pts
VII) Remarques :
root@RaspberryPi [/root]# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 3.5G 42.7M 3.3G 1% /
devtmpfs 226.9M 0 226.9M 0% /dev
VIII) Liens : http://www.blaess.fr/christophe/2013/02/28/linux-mag-158-raspberry-pi-from-scratch/