Skip to content

Instantly share code, notes, and snippets.

@mmalchuk
Created January 16, 2018 19:28
Show Gist options
  • Save mmalchuk/9b0d71b254ca17de5b393ac3ca58a7f8 to your computer and use it in GitHub Desktop.
Save mmalchuk/9b0d71b254ca17de5b393ac3ca58a7f8 to your computer and use it in GitHub Desktop.
CentOS on the Raspberry Pi 3

CentOS on the Raspberry Pi 3

Installation

  • Download the official image from mirror.centos.org:
    • e.g. curl http://mirror.centos.org/altarch/7/isos/armhfp/CentOS-Userland-7-armv7hl-Minimal-1708-RaspberryPi3.img.xz > CentOS.img.xz
  • Write the image you downloaded above:
    • e.g. xzcat CentOS.img.xz | dd of=/path/to/sd/card status=progress bs=4M; sync

Configuration

  • Boot your Raspberry Pi:
    • root password: centos
  • Change the default password and add a new user:
    • passwd root: type root's password
    • adduser username and passwd username: add a new user without sudo privileges
    • gpasswd -a username wheel: granting sudo privileges to a new user
  • Set the system hostname:
    • e.g. hostnamectl set-hostname RaspberryPi
  • Set the system time:
    • timedatectl list-timezones | grep Europe: choose your time zone
    • e.g. timedatectl set-timezone Europe/Astrakhan
  • Set the system locale:
    • localectl set-locale LANG="en_US.utf8" LC_NUMERIC="C" LC_TIME="POSIX" LC_MESSAGES="POSIX"
    • localectl set-keymap us ru --no-convert
    • localectl set-x11-keymap us,ru pc105 grp:ctrl_shift_toggle --no-convert
    • echo "FONT=UniCyr_8x16" >> /etc/vconsole.conf
  • Configure SSH settings file /etc/ssh/sshd_config:
Port 2222

LogLevel QUIET
SyslogFacility DAEMON

HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_rsa_key

Ciphers aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected]
KexAlgorithms diffie-hellman-group-exchange-sha256,[email protected]
MACs [email protected],[email protected]

AcceptEnv LANG LC_*
ChallengeResponseAuthentication no
LoginGraceTime 1m
MaxAuthTries 3
PrintLastLog no
UseDNS no
UsePAM yes
  • Uninstall firewalld and install iptables:
    • Turn off daemon:
      • systemctl stop firewalld
      • systemctl disable firewalld
    • Delete the package and dependencies:
      • yum remove firewalld
      • yum autoremove
    • Install the iptables' dependencies: yum install iptables-services iptables-utils
    • Reanimate the iptables daemon:
      • systemctl enable iptables.service
      • systemctl start iptables.service

Connection

  • List available Wi-Fi access points: nmcli device wifi list
  • Connect to a Wi-Fi network specified by SSID: nmcli device wifi connect "SSID" password "password_for_secured_networks"

Installing 3rd Party Applications

Requirements: yum install bzip2-devel expat-devel gdbm-devel libpcap-devel ncurses-devel openssl-devel readline-devel sqlite-devel tk-devel xz-devel zlib-devel

Python 3.6.3

curl https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz > Python-3.6.3.tar.xz
tar xf Python-3.6.3.tar.xz
cd Python-3.6.3
./configure --enable-optimizations --prefix=/usr/local --enable-shared LDFLAGS="-Wl,rpath /usr/local/lib"
make altinstall

Useful Stuff

  • Get temperature of CPU: cat /sys/class/thermal/thermal_zone0/temp
  • Backup system: dd if=/dev/mmcblk0 bs=4M status=progress conv=noerror | xz --stdout > /path/to/external/disk/backup.img.xz
  • Pretty prompt: add export PS1='\[\e[0;32m\]\u \[\e[1;34m\]\w \[\e[1;32m\]\$ \[\e[m\]' to .bashrc

Licensed under the terms of the CC0 1.0 Universal License.

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