385 lines
7.5 KiB
Markdown
385 lines
7.5 KiB
Markdown
# Réseau et partage
|
|
|
|
|
|
|
|
#### Configurer le réseau wifi:
|
|
|
|
```bash
|
|
$ nano /etc/wpa_supplicant/wpa_supplicant.conf
|
|
|
|
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
|
|
update_config=1
|
|
country=FR
|
|
|
|
network={
|
|
ssid="Bart_nomap"
|
|
psk="ma_clef_wifi"
|
|
key_mgmt=WPA-PSK
|
|
}
|
|
```
|
|
|
|
```bash
|
|
# Recharger les nouvelles configurations
|
|
$ wpa_cli -i wlan0 reconfigure
|
|
```
|
|
|
|
|
|
|
|
#### Encoder le mot de passe:
|
|
|
|
```bash
|
|
$ wpa_passphrase "Bart_nomap"
|
|
|
|
# reading passphrase from stdin
|
|
|
|
ma_clef_wifi
|
|
network={
|
|
ssid="Bart_nomap"
|
|
#psk="ma_clef_wifi"
|
|
psk=40e6467b0ab3569a63dfe33001abb3a6b8757989937091f3edf7c9d9bd508ede7
|
|
}
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
$ nano /etc/network/interfaces
|
|
### (ne pas changer !!!) ###
|
|
|
|
# interfaces(5) file used by ifup(8) and ifdown(8)
|
|
# Please note that this file is written to be used with dhcpcd
|
|
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
|
|
# Include files from /etc/network/interfaces.d:
|
|
source-directory /etc/network/interfaces.d
|
|
```
|
|
|
|
#### Adresses IP:
|
|
|
|
```bash
|
|
$ ip -4 addr | grep inet
|
|
inet 192.168.1.254/24 brd 192.168.1.255 scope global eth0
|
|
inet 192.168.1.21/24 brd 192.168.1.255 scope global wlan0
|
|
```
|
|
|
|
#### Adresse du routeur (gateway):
|
|
|
|
```bash
|
|
$ ip route | grep default | awk '{print $3}'
|
|
192.168.1.1
|
|
192.168.1.1
|
|
```
|
|
|
|
#### Adresse du serveur DNS:
|
|
|
|
```bash
|
|
$ cat /etc/resolv.conf
|
|
|
|
# Generated by resolvconf
|
|
|
|
domain home
|
|
nameserver 192.168.1.1
|
|
nameserver fe80::4265:a3ff:fec3:8132%eth0
|
|
nameserver fe80::4265:a3ff:fec3:8132%wlan0
|
|
```
|
|
|
|
#### Liste des noms d'interface
|
|
|
|
```bash
|
|
$ ls /sys/class/net
|
|
eth0 lo wlan0
|
|
```
|
|
|
|
```bash
|
|
$ ifconfig
|
|
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
|
|
ether dc:a6:32:55:56:e0 txqueuelen 1000 (Ethernet)
|
|
RX packets 0 bytes 0 (0.0 B)
|
|
RX errors 0 dropped 0 overruns 0 frame 0
|
|
TX packets 0 bytes 0 (0.0 B)
|
|
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
|
|
|
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
|
|
inet 127.0.0.1 netmask 255.0.0.0
|
|
inet6 ::1 prefixlen 128 scopeid 0x10<host>
|
|
loop txqueuelen 1000 (Boucle locale)
|
|
RX packets 375 bytes 32464 (31.7 KiB)
|
|
RX errors 0 dropped 0 overruns 0 frame 0
|
|
TX packets 375 bytes 32464 (31.7 KiB)
|
|
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
|
|
|
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
|
inet 192.168.2.251 netmask 255.255.255.0 broadcast 192.168.2.255
|
|
inet6 fe80::e55e:a7fc:915f:fb98 prefixlen 64 scopeid 0x20<link>
|
|
ether dc:a6:32:55:56:e1 txqueuelen 1000 (Ethernet)
|
|
RX packets 91361 bytes 29942853 (28.5 MiB)
|
|
RX errors 0 dropped 0 overruns 0 frame 0
|
|
TX packets 22382 bytes 3480690 (3.3 MiB)
|
|
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Mettre en IP fixe:
|
|
|
|
```bash
|
|
$ sudo nano /etc/dhcpcd.conf
|
|
|
|
# à rajouter à la fin du fichier:
|
|
|
|
interface eth0
|
|
static ip_address=192.168.2.252/24
|
|
static routers=192.168.2.1
|
|
static domain_name_servers=8.8.8.8 8.8.4.4
|
|
|
|
interface wlan0
|
|
static ip_address=192.168.2.251/24
|
|
static routers=192.168.2.1
|
|
static domain_name_servers=8.8.8.8 8.8.4.4
|
|
```
|
|
|
|
#### Modifier le hostname:
|
|
|
|
```bash
|
|
$ sudo raspbi-config
|
|
# 1 System Options puis S4 Hostname
|
|
```
|
|
|
|
```bash
|
|
$ sudo nano /etc/hosts
|
|
|
|
127.0.0.1 localhost
|
|
::1 localhost ip6-localhost ip6-loopback
|
|
ff02::1 ip6-allnodes
|
|
ff02::2 ip6-allrouters
|
|
|
|
127.0.1.1 raspberrypi4
|
|
```
|
|
|
|
puis
|
|
|
|
```bash
|
|
$ sudo nano /etc/hostname
|
|
raspberrypi4
|
|
```
|
|
|
|
|
|
|
|
#### Redémarrer le service réseau:
|
|
|
|
```bash
|
|
$ service networking restart
|
|
```
|
|
|
|
|
|
|
|
#### VNC:
|
|
|
|
*VNC Server (Pi):*
|
|
|
|
Menu → Options:
|
|
|
|
- Sécurité:
|
|
|
|
- Chiffrement: De préférence actif
|
|
- Authentification: Mot de passe VNC
|
|
|
|
- Utilisateurs et autorisations:
|
|
|
|
- Utilisateur standart: Mot de passe
|
|
|
|
|
|
|
|
*VNC Viewer (Mac):*
|
|
|
|
Port 5900
|
|
|
|
|
|
|
|
#### SSH:
|
|
|
|
Changer le port par défaut (22):
|
|
|
|
```bash
|
|
$ sudo nano sshd_config
|
|
|
|
#Décommenter la ligne # Port 22 et modifier le port
|
|
Port 39517
|
|
|
|
$ sudo service ssh restart
|
|
```
|
|
|
|
#### Ajouter la clé ssh:
|
|
|
|
```bash
|
|
bruno@silverbook:~/.ssh$ ssh pi@framboise.local 'mkdir -p ~/.ssh; chmod 0700 ~/.ssh; echo ' $(< ~/.ssh/id_ed25519.pub) ' >> ~/.ssh/authorized_keys ; chmod 0600 ~/.ssh/authorized_keys'
|
|
```
|
|
|
|
|
|
|
|
#### Installer Samba:
|
|
|
|
Installer et créer un répertoire partagé:
|
|
|
|
```bash
|
|
$ sudo apt-get install apt-transport-https samba samba-common-bin
|
|
$ sudo mkdir -p /home/pi/share
|
|
$ sudo chown -hR pi:pi /home/pi/share
|
|
$ sudo chmod 777 /home/pi/share
|
|
```
|
|
|
|
#### Sauvegarder le fichier de configuration
|
|
|
|
```bash
|
|
$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
|
|
```
|
|
|
|
#### Editer le fichier smb.conf:
|
|
|
|
```bash
|
|
$ sudo nano /etc/samba/smb.conf
|
|
|
|
## Browsing/Identification ###
|
|
# Change this to the workgroup/NT-domain name your Samba server will part of
|
|
workgroup = WORKGROUP
|
|
wins support = yes
|
|
|
|
####### Authentication #######
|
|
security = user
|
|
|
|
[homes]
|
|
read only = no
|
|
|
|
[Share]
|
|
comment = Partage Samba sur Raspberry
|
|
path=/home/pi/share
|
|
browseable=Yes
|
|
writeable=Yes
|
|
only guest=no
|
|
create mask=0777
|
|
directory mask=0777
|
|
public=no
|
|
```
|
|
|
|
#### Créer un utilisateur Samba:
|
|
|
|
```bash
|
|
$ sudo smbpasswd -a pi
|
|
New SMB password:
|
|
Retype new SMB password:
|
|
Added user pi.
|
|
```
|
|
|
|
#### Tester la config Samba:
|
|
|
|
```bash
|
|
$ testparm
|
|
Load smb config files from /etc/samba/smb.conf
|
|
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
|
|
WARNING: The "syslog" option is deprecated
|
|
Processing section "[homes]"
|
|
Processing section "[printers]"
|
|
Processing section "[print$]"
|
|
Processing section "[Share]"
|
|
Loaded services file OK.
|
|
Server role: ROLE_STANDALONE
|
|
|
|
Press enter to see a dump of your service definitions
|
|
|
|
# Global parameters
|
|
[global]
|
|
log file = /var/log/samba/log.%m
|
|
max log size = 1000
|
|
syslog = 0
|
|
panic action = /usr/share/samba/panic-action %d
|
|
usershare allow guests = Yes
|
|
map to guest = Bad User
|
|
obey pam restrictions = Yes
|
|
pam password change = Yes
|
|
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
|
|
passwd program = /usr/bin/passwd %u
|
|
server role = standalone server
|
|
unix password sync = Yes
|
|
dns proxy = No
|
|
wins support = Yes
|
|
idmap config * : backend = tdb
|
|
|
|
|
|
[homes]
|
|
comment = Home Directories
|
|
browseable = No
|
|
create mask = 0700
|
|
directory mask = 0700
|
|
valid users = %S
|
|
|
|
|
|
[printers]
|
|
comment = All Printers
|
|
path = /var/spool/samba
|
|
browseable = No
|
|
printable = Yes
|
|
create mask = 0700
|
|
|
|
|
|
[print$]
|
|
comment = Printer Drivers
|
|
path = /var/lib/samba/printers
|
|
|
|
|
|
[Share]
|
|
comment = Partage Samba sur Raspberry
|
|
path = /home/pi/share
|
|
create mask = 0777
|
|
directory mask = 0777
|
|
read only = No
|
|
|
|
```
|
|
|
|
**Messages d'erreurs:**
|
|
|
|
`rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)`
|
|
|
|
```bash
|
|
# Global files limit:
|
|
|
|
$ cat /proc/sys/fs/file-max
|
|
88603
|
|
|
|
# Local files limit:
|
|
|
|
$ ulimit -Hn
|
|
1048576
|
|
$ ulimit -Sn
|
|
1024
|
|
|
|
# Modifier temporairement les limites:
|
|
|
|
ulimit -Hn n
|
|
ulimit -Sn m
|
|
|
|
# Modifier les limites:
|
|
|
|
Editer /etc/security/limits.conf et ajouter:
|
|
samba soft nofile 16384
|
|
samba hard nofile 32768
|
|
```
|
|
|
|
`WARNING: The "syslog" option is deprecated`
|
|
commenter la ligne syslog: `#syslog = 0`
|
|
|
|
#### Redémarrer Samba:
|
|
|
|
```bash
|
|
$ sudo /etc/init.d/samba restart
|
|
```
|
|
|
|
|
|
|
|
#### Liens:
|
|
|
|
[:fa-link: http://nagashur.com/blog/2016/07/21/partage-de-fichiers-samba-avec-le-raspberry-pi/](http://nagashur.com/blog/2016/07/21/partage-de-fichiers-samba-avec-le-raspberry-pi/)
|
|
|
|
[:fa-link: https://gist.github.com/masterT/407a6d9e30ba4169bb39](https://gist.github.com/masterT/407a6d9e30ba4169bb39)
|
|
|
|
[:fa-link: http://www.framboise314.fr/partager-un-repertoire-sous-jessie-avec-samba/](http://www.framboise314.fr/partager-un-repertoire-sous-jessie-avec-samba/) |