Skip to content

Raspberry Pi

Install Raspbian

Official docs.

Download image, verify the checksum and write it on SD card:

1
2
3
4
5
6
7
8
9
wget https://downloads.raspberrypi.org/raspbian_lite_latest
echo "9e5cf24ce483bb96e7736ea75ca422e3560e7b455eee63dd28f66fa1825db70e raspbian_lite_latest" | sha256sum --check
raspbian_lite_latest: OK
unzip raspbian_lite_latest
sudo dd bs=4M if=2019-07-10-raspbian-buster-lite.img of=/dev/sdX status=progress conv=fsync

# Double-check it has been written successfully
sudo dd bs=4M if=/dev/sda of=from-sd-card.img count=524
echo "9e5cf24ce483bb96e7736ea75ca422e3560e7b455eee63dd28f66fa1825db70e from-sd-card.img" | sha256sum --check

SSH

  • Enable ssh-agent on your main host and copy your public ssh key to RPi: ssh-copy-id pi@192.168.0.11 -p 222
  • Generate keys on RPi: ssh-keygen -t ecdsa -b 521

  • Enable SSH server on RPi

    sudo systemctl enable ssh.service
    sudo systemctl start ssh.service
    

Setup auto screen on ssh login

nano ~/.bashrc
+ # Auto-screen invocation. see: http://taint.org/wk/RemoteLoginAutoScreen
+ # if we're coming from a remote SSH connection, in an interactive session
+ # then automatically put us into a screen(1) session.   Only try once
+ # -- if $STARTED_SCREEN is set, don't try it again, to avoid looping
+ # if screen fails for some reason.
+ if [ "$PS1" != "" -a "${STARTED_SCREEN:-x}" = x -a "${SSH_TTY:-x}" != x ]
+ then
+    STARTED_SCREEN=1 ; export STARTED_SCREEN
+    screen -RR && exit 0
+    # normally, execution of this rc script ends here...
+    echo "Screen failed! continuing with normal bash startup"
+ fi
+ # [end of auto-screen snippet]
nano ~/.screenrc
# Enable scroll in screen
defscrollback 10000
termcapinfo xterm* ti@:te@

# see http://www4.informatik.uni-erlangen.de/~jnweiger/screen-faq.html
# support color X terminals
termcap  xterm 'XT:AF=\E[3%dm:AB=\E[4%dm:AX'
terminfo xterm 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX'
termcapinfo xterm 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX:hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
termcap  xtermc 'XT:AF=\E[3%dm:AB=\E[4%dm:AX'
terminfo xtermc 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX'
termcapinfo xtermc 'XT:AF=\E[3%p1%dm:AB=\E[4%p1%dm:AX:hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'

# auto-screen support; see http://taint.org/wk/RemoteLoginAutoScreen
# detach on hangup
autodetach on

# no startup msg
startup_message off

# always use a login shell
shell -$SHELL

3g/4g usb modem

You can use any 3g/4g usb modem. For example one of these modems.

After installing Raspberry Pi we need to initialise a system that will allow us to connect to Raspberry Pi via SSH access. For this we will setup a virtual machine using Google Cloud. The tutorial on how to do it is here.