RaspberryPi Version 3 SOE
By Leo Gaggl
Since there is now a supported Raspbian version without GUI and other unneeded add-ons available as Raspbian Lite the need to use other installers (with sometimes some downsides) is now not a necessity anymore. Below is a list of steps I like to perform before using them for any purpose as my Standard Operating Environment.
Download Raspbian Lite
Download link: https://www.raspberrypi.org/downloads/raspbian/
Write to SD Card
dd bs=4M if=2016-05-27-raspbian-jessie-lite.img of=/dev/sdb
Boot RPi
Default login details are
UID: pi
PWD: rasbperry
Regional settings
locale-gen en_AU.UTF-8<br></br>dpkg-reconfigure locales<br></br>ln -sf /usr/share/zoneinfo/Australia/Adelaide /etc/localtime
System update
sudo apt update && sudo apt -y upgrade<br></br>apt install vim
Setup SSH keys
As a security precausion it’s a good idea to disable password authentications
ssh-keygen -t rsa<br></br>vim /root/.ssh/authorized_keys<br></br># --> add RSA public key
Setup Wireless LAN
iwlist wlan0 scan<br></br>wpa_passphrase SSID WPA_KEY<br></br>vim /etc/wpa_supplicant/wpa_supplicant.conf
Copy the resulting hash from the previous command
Example config
country=AU<br></br>ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev<br></br>update_config=1<br></br>network={<br></br>ssid="YOURSSID"<br></br>psk=123456789012345678901234567890<br></br>}
Rename default user account
The default Raspbian images use the default user ‘pi’ – I prefer to change this user to another account for security purposes and to be in line with other Linux system I use.
Reboot and log in to the RPi as root – you need to run the following commands as root.
usermod -l NEW_USER_ID pi<br></br>usermod -m -d /home/NEW_USER_ID NEW_USER_ID<br></br>groupmod --new-name NEW_USER_ID pi<br></br>mkdir /home/NEW_USER_ID/.ssh/<br></br>vim /home/NEW_USER_ID/.ssh/authorized_keys<br></br># --> add RSA public key<br></br># change owner and permissions on key files<br></br>chown -R NEW_USER_ID:NEW_USER_ID /home/NEW_USER_ID/.ssh/<br></br>chmod 700 /home/NEW_USER_ID/.ssh/<br></br>chmod 600 /home/NEW_USER_ID/.ssh/authorized_keys<br></br>rm /etc/sudoers.d/010_pi-nopasswd<br></br>echo 'NEW_USER_ID ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/010_NEW_USER_ID-nopasswd
If you are using the desktop version not a headless version you want to make sure you don’t boot into the desktop and if you want to change the autologin ensure you update the username there as well.
/etc/systemd/system/autologin@.service
/etc/lightdm/lightdm.conf
Configure Raspberry Pi settings
raspi-config
I generally need to enable SPI, change the hostname and others depending on the purpose of the unit.
EDIT [2017-08-21]: With the update of Raspbian to Stretch you now have the firmware updater as part of the Raspbian repos:
sudo rpi-update
This will update the Pi Firmware to the latest version as well – which is worth it if you use it for later cameras and peripheral usage.
EDIT [2017-12-27]: change annoying vim defaults in Debian Stretch onwards. Visual mode.
sudo vim /usr/share/vim/vim81/defaults.vim
Comment out the following lines:
“if has(‘mouse’)
” set mouse=a
“endif