User:E.zn/rpi
< User:E.zn
Revision as of 23:16, 1 June 2021 by E.zn (talk | contribs) (→___________________________________SD card)
- Raspberry Pi is a single-board computer
___________________________________SD card
_ _ _ _ _ Download .img
- Download RPi image from raspberrypi.org either manually or using
wget
. For instance, the latest release of Raspberry Pi OS Lite at the time of writing this is2021-01-11-raspios-buster-armhf-lite.zip
- Download RPi image from raspberrypi.org either manually or using
wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-01-12/2021-01-11-raspios-buster-armhf-lite.zip
_ _ _ _ _ Verify Hash Key
- Hash key [ sha256 ] is provided on the website, next to the RPi image info. For
2021-01-11-raspios-buster-armhf-lite.zip
, it'sd49d6fab1b8e533f7efc40416e98ec16019b9c034bc89c59b83d0921c2aefeef
.
- Hash key [ sha256 ] is provided on the website, next to the RPi image info. For
sha256sum ~/Downloads/2021-01-11-raspios-buster-armhf-lite.zip
_ _ _ _ _ Unzip
unzip 2021-01-11-raspios-buster-armhf-lite.zip
_ _ _ _ _ Check mounted devices
- When you have an SD card inserted in your laptop, it will show up as a partition[s] on the list of mounted devices :
/dev/mmcblk0<#>
[in my case:/dev/mmcblk0
] df -h
- When you have an SD card inserted in your laptop, it will show up as a partition[s] on the list of mounted devices :
_ _ _ _ _ Unmount
- Unmount the SD card partition[s] [in this case it's only
/dev/mmcblk0
]
- Unmount the SD card partition[s] [in this case it's only
umount /dev/mmcblk0
_ _ _ _ _ .img-to-SD
- To write the image to the SD card, run the following command, but make sure
of=
argument output is a correct device name, meaning the whole SD card and not one of its partitions!
- To write the image to the SD card, run the following command, but make sure
sudo dd bs=4M status=progress if=2021-01-11-raspios-buster-armhf-lite.img of=/dev/mmcblk0
sudo sync
_ _ _ _ _ ssh file
- Create a file named
ssh
in a boot partition
- Create a file named
cd /media/ezn/boot
touch ssh
- SD card is good to go. Insert the card in RPi before powering it on, and shutdown the Raspberry Pi before unplugging the card.
___________________________________RPi
- Default user:
pi
- Default pwd:
raspberry
- Default hostname:
raspberrypi
- Default user:
_ _ _ _ _ ssh
- Connect your RPi to a router with an ethernet cable. To try to ssh into it using the default credentials
ssh pi@raspberrypi
- If it didn't work, find the RPi IP address first. For this reason, scan your local network
nmap -sn 192.168.1.1-255
- I'm gonna use my RPi IP address [
192.168.1.4
], and default username [pi
] and password [raspberry
] to ssh into it
- I'm gonna use my RPi IP address [
ssh pi@192.168.1.4
- In case you get the following message:
Wi-Fi is currently blocked by rfkill
- In case you get the following message:
sudo rfkill unblock 0
_ _ _ _ _ Hostname
- To change the hostname from the default
raspberrypi
to your desired one
- To change the hostname from the default
sudo raspi-config
- Go to
System Options
, selectHostname
and rename it. Then<Ok>
and<Finish>
. You'll be asked to reboot the RPi.
- Go to
_ _ _ _ _ Add a user
- Switch to
root
- Switch to
sudo -i
- To add a user [
ezn
, for instance]
- To add a user [
adduser ezn
- You'll be prompted to set a password for this user
- To add
ezn
to a sudo group
- To add
adduser ezn sudo
- To check if
ezn
is indeed sudo
- To check if
id ezn
- If
ezn
is a sudo user, the command should output27(sudo)
at the end of the line, afteruid
,gid
andgroups
.
- If
- To switch to a specific user
sudo su - ezn
_ _ _ _ _ Remove default pi user
- Since during the configuration, we initially logged in as
pi
, we need to log out from it first and then delete it. So, runlogout
orexit
until you're completely out and then ssh back into RPi asezn
- Since during the configuration, we initially logged in as
ssh ezn@192.168.1.4
sudo -i
deluser pi
- To check a list of users
cut -d: -f1 /etc/passwd
_ _ _ _ _ Setting locale
sudo -i
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen en_US.UTF-8
_ _ _ _ _ public/private keys
- To generate a public/private key pair, on your machine [laptop] run
ssh-keygen -t ed25519 -b 320
- Both public [
id_ed25519.pub
] and private [id_ed25519
] keys are stored in a hidden.ssh
folder in theHome
directory.
- Both public [
- To securely copy the contents of the public key into an
authorized_keys
file on your RPi [run this on your machine]
- To securely copy the contents of the public key into an
cat ~/.ssh/id_ed25519.pub | ssh ezn@192.168.1.4 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
_ _ _ _ _ Disable pwd and root login
sudo nano /etc/ssh/sshd_config
- Uncomment
PermitRootLogin prohibit-password
- Uncomment
PubkeyAuthentication yes
- Uncomment and set it to
no
- Uncomment and set it to
PasswordAuthentication no
- Save changes
Ctrl + s
Ctrl + x
_ _ _ _ _ Reload SSH
sudo /etc/init.d/ssh restart
_ _ _ _ _ Reboot
sudo reboot
_ _ _ _ _ Login with a Host name
- To ssh w/a Host name [
watermelon
, for example] as opposed tossh ezn@192.168.1.4
orssh ezn@kibkadar
, you'll need to modify theconfig
file in.ssh
directory. Open it:
- To ssh w/a Host name [
sudo nano ~/.ssh/config
- and add the following:
- Host watermelon
- User ezn
- Hostname 192.168.1.4
- Port 22
- Identityfile /home/ezn/.ssh/id_ed25519
- Serveraliveinterval 30
Ctrl + s
Ctrl + x
- Now you can ssh as Host
ssh watermelon
-----------------------------------------------------------------------------
- For Nginx and Tor setup >> instructions by Aymeric