Skip to content

Instantly share code, notes, and snippets.

@leophys
Created January 10, 2021 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leophys/f60af883ff1c29d4014f040d733ebfa2 to your computer and use it in GitHub Desktop.
Save leophys/f60af883ff1c29d4014f040d733ebfa2 to your computer and use it in GitHub Desktop.
How to Debian on a Raspberry Pi

Flash debian on a microSD card to be used on a raspberry pi

Download

Download from here the appropriate image.

Flash

Flash the image on the appropriate device. Full device, not a partition, so no number at the end of the device name, i.e. /dev/sdc, not /dev/sdc2:

$ xzcat <raspi_image>.img.xz | sudo dd of=/dev/<YOUR_DEVICE> bs=64k oflag=dsync status=progress

Add your key to authorized_key

Mount the newly created root partition (number 2, assuming the device is /dev/sda) to a mount point:

$ MOUNTPOINT=/mnt/
$ sudo mount /dev/sda2 $MOUNTPOINT

Copy your ssh key to root's authorized_key:

$ sudo mkdir $MOUNTPOINT/root/.ssh
$ echo "<YOUR_SSH_PUBLIC_KEY> | sudo tee -a $MOUNTPOINT/root/.ssh/authorized_key"
$ sudo chmod 600 $MOUNTPOINT/root/.ssh/authorized_key
$ sudo chmod 700 $MOUNTPOINT/root/.ssh/

ssh.service unit is yet enabled. Modify $MOUNTPOINT/etc/ssh/sshd_config to allow root login, uncommenting the line with PermitRootLogin to obtain:

PermitRootLogin prohibit-password

Configure network

Debian supports the old way via /etc/network/interfaces. Modify $MOUNTPOINT/etc/network/interfaces.d/eth0:

auto eth0
iface eth0 inet static
    address <raspi_address>
    submask <netmask>
    gateway <gateway_address>

Most likely:

  • address: 192.168.1.i being i a number in the 1-255 range
  • netmask: 255.255.255.0
  • gateway: 192.168.1.1

Plug the raspberry

Plug the raspberry in a socket and attach the ethernet cable. ssh into it with

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment