Setting up a Raspberry Pi (5)

Part 5: Cheat sheet, index.

  • Part 1: Getting the Hardware and Operating System ready.
    • Step 1, Get the software for “burning”/”etching” the OS.
    • Step 2, “Burning”/”etching” the OS to the SD-Card.
    • Step 3, Getting “SSH” setup:
      • Create a empty txt file on the “Boot” drive, root folder,
      • Name it: ssh
        without the: .txt
    • Step 4, Getting “Headless setup” setup.
      • Create the empty network txt file, on the “Boot” drive, root folder,
      • Name it: wpa_supplicant.conf
      • add the following, and save it:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=NL 

network={
 ssid="yourWifiNetworkName" 
 psk="yourRealyH4rdP455word" 
  • Part 1(cont.):
    • Remove Micro SD card from the PC.
    • Put Micro SD card in the Raspberry Pi and connect power.

  • Part 2: Starting up the Raspberry Pi for the 1st time.
    • Step 1, finding out what IP address your Raspberry Pi is using.
    • Step 2, Getting connected by SSH with PowerShell.
      • ssh [email protected] << use your Raspberry Pi IP
      • yes
        If it is a PI address that was used before with SSH, go to: 
        this PC > Windows (C:) > Users > "your username" > .ssh
        open the known_hosts file, with “Notepad”, delete the line with the same IP
      • Default password: 
        raspberry
        remember Linux does not show anything when entering passwords
    • Step 3, Change the default Password !!!
      • passwd
    • Step 4, Expanding Storage Space / File system
      • sudo raspi-config.
      • Option: 7 Advanced Options ....
      • Option: A1 Expand Filesystem ....
    • Step 5, Change Localization (while we are here).
      • Option: 4 Localisation Options ....
      • Option:  I1 Change locale ..
      • For me: nl_NL.UTF-8 UTF-8.
      • select the Default locale, for the system environment.
      • For me : en_GB.UTF-8.
      • Option: 4 Localisation Options ....
      • Option: I2 Change Timezone
      • For me: Europe
      • For me: Amsterdam
      • Option: 4 Localisation Options ....
      • Option: I3 Change keyboard layout
    • press [Tab] to go to the <Select> and press [↓] or [Tab] to go to <Finish> and press [Enter], (wait with reboot till after Step 6).
    • Step 6, Set a Fixed IP address for the Raspberry Pi.
      • Access your Router and appoint a fixed IP address to the Raspberry PI.
      • Now press [Enter] to reboot (in the “PowerShell”, on question if you want to reboot now).
        If you already did, or skipped it, use: sudo reboot.
    • Step 7, Reconnect to the Raspberry Pi.
      • ssh [email protected] << use your (new) Raspberry Pi IP address
      • Type your new password: ****

  • Part 3: Updating the Raspberry Pi, and setting up for USB boot.
    • Step 1, Keeping your Operating System and packages/software up to date.
      • sudo apt update.
      • sudo apt upgrade or sudo apt upgrade -y .
      • sudo reboot.
        Not (really/always) needed, but I tend to do it anyway.
    • Step 2, Setting up the Raspberry Pi 4 to be able to boot from USB.
      Only for Raspberry Pi 4, it does not work on the Raspberry Pi Zero, with out jumping thru to many hoops.
      – You do need to have ran, sudo apt update & sudo apt upgrade -y
      – You need to have expanded the filesystem before running apt upgrade.
      • sudo raspi-config.
      • Option: 3 Boot Options ….
      • Option: B5 Boot ROM Version ….
      • Option: E1 Latest ….
      • Reset boot ROM to defaults?
        I have no idea what really is the right answer, I have seen both, but <No> seems is the most suggested option, so if it does not work try <Yes>??

        !!! note of caution, as of writing of this post the next steps are the default option, so you can leave it and skip these 3 steps,
        If you still decide to set it, it will be permanently as in irreversible. !!!
      • Option: 3 Boot Options ….
      • Option: B4 Boot Order ….
      • Option: B1 USB Boot ….
        If in the future, the default option changes, this Raspberry Pi 4 will keep booting from “USB if there is no Micro SD card”. so skip this step if you might want to boot from network or whatever order they might come up with in the future !
      • Depending if you want to connect a USB storage device right now:
        – skip the reboot,
        – type sudo shutdown,
        – disconnect power,
        – remove Micro SD card,
        – connect USB storage device,
        – reconnect power.
        if not right now: Than just select to reboot.

  • Part 4: Setting up SSH, Encrypted Key, Disable Password use, SSH Alias.
    • Step 1: SSH Key setup
      • Install the OpenSSH software to create the key.
        sudo apt install openssh-server
      • cd ~
      • mkdir .ssh
      • chmod 700 .ssh
        setting the read and write properties so only user pi can see and access these
      • cd .ssh
      • ssh-keygen -t rsa -b 4096 -f rpi_key
        creating the actual key’s
      • cat rpi_key.pub >> authorized_keys
      • exit
        next step is back on the PC not on the Raspberry Pi
      • scp [email protected]:/home/pi/.ssh/rpi_key ./.ssh/rpi_1_key
      • Trying out is the key works:
        ssh [email protected] -i ./.ssh/rpi_1_key
    • Step 2: Disable SSH using a password to login
      • sudo nano /etc/ssh/sshd_config
      • change:
        #passwordauthentication yes
        and change it to:
        passwordautentication no
      • sudo service ssh restart
      • exit
      • ssh [email protected] << Should FAIL
      • ssh [email protected] -i ./.ssh/rpi_1_key << Should work
    • Step 3: SSH alias setup
      • this PC > Windows (C:) > Users > "your username" > .ssh
      • Create a txt file and name it: config
        without extension
      • add the code :
add: Host pi1
HostName 192.168.100.100
User pi
IdentityFile ~/.ssh/rpi_1_key
  • Part 4 (cont.):
    • Connect to Raspberry Pi with
      ssh pi1

^ Back to the Top ^

<< Part Part 4, Setting up SSH, Encrypted Key, Disable Password use, SSH Alias.

Leave a Reply

Your email address will not be published. Required fields are marked *