Installez-vous sur le PC du réseau à relier au Raspberry Pi.
Retrouvez le Raspberry Pi sur le réseau en lançant :
...@...:~$ ping raspberrypi.local -c 1 PING raspberrypi.local (192.168.0.21) 56(84) bytes of data. 64 bytes from 192.168.0.21 (192.168.0.21): icmp_seq=1 ttl=64 time=245 ms --- raspberrypi.local ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 245.513/245.513/245.513/0.000 ms
On constate que :
Lancez une session SSH sur l'adresse du Raspberry Pi sous l'utilisateur pi (l'adresse réseau du Raspberry Pi, retrouvée par nmap, est supposée 192.168.0.31) :
...@...:~$ ssh pi@raspberrypi.local Warning: the ECDSA host key for 'raspberrypi.local' differs from the key for the IP address '192.168.0.31' Offending key for IP in /home/nicolas/.ssh/known_hosts:11 Matching host key in /home/nicolas/.ssh/known_hosts:12 Are you sure you want to continue connecting (yes/no)? yes pi@raspberrypi.local's password: Linux raspberrypi 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Jul 30 21:32:10 2020 SSH is enabled and the default password for the 'pi' user has not been changed. This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password. pi@raspberrypi:~ $
En cas de réinstallation, Il se peut qu'un message s'affiche :
...:~$ ssh pi@192.168.0.31 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ... remove with: ssh-keygen -f "/home/xxxxxxx/.ssh/known_hosts" -R "192.168.0.31" ... Host key verification failed.
Dans ce cas, faites comme demandé :
$ ssh-keygen -f "/home/xxxxxxx/.ssh/known_hosts" -R 192.168.0.31
et recommencez.
Pour ne pas avoir à fournir le mot de passe à chaque connexion SSH au Raspberry Pi,
...:~$ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/xxxxxxx/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/xxxxxxx/.ssh/id_dsa. Your public key has been saved in /home/xxxxxxx/.ssh/id_dsa.pub. The key fingerprint is: SHA256:kVpG+4aYTuDIvXIDg7vfTbGHTcw7p9MVHR2kFbRYI44 nicolas@chateau The key's randomart image is: +---[DSA 1024]----+ | . .oXo| | . o o B +| | . * E = o | | o + . O + . . | |. = o * S o . | | . o + * o . | |. . + = =... | | . + + ..+. | |... . . .. | +----[SHA256]-----+ ...:~$
Répondez ↵ Entrée à chaque fois pour ne pas avoir de mot de passe et acceptez les noms de fichier.
...:~$ ssh-copy-id pi@192.168.0.31 /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 2 key(s) remain to be installed -- if you are prompted now it is to install the new keys pi@192.168.0.31's password: Number of key(s) added: 2 Now try logging into the machine, with: "ssh 'pi@192.168.0.31'" and check to make sure that only the key(s) you wanted were added.
$ ssh pi@192.168.0.31
et donnez une dernière fois le mot de passe.
Pour automatiser cette connexion,
Host framboise User pi Hostname 192.168.0.31 # framboise.local Port 22 CheckHostIP no LocalForward 5900 127.0.0.1:5900 Compression yes ForwardX11 yes
Il suffit maintenant de :
$ ssh framboise
pour lancer une session SSH sur le Raspberry Pi :
$ ssh pi@192.168.0.31 sign_and_send_pubkey: signing failed: agent refused operation
Les autorisations de fichier sont trop ouvertes (0644).
Solution Les changer ainsi :
$ chmod 600 ~/.ssh/id_rsa