2966
Comment: Disable root login via SSH
|
5314
|
Deletions are marked like this. | Additions are marked like this. |
Line 25: | Line 25: |
cat /etc/ssh/sshd_config | sed "s/PermitRootLogin yes/PermitRootLogin without-password/" > /etc/ssh/sshd_config.tmp mv /etc/ssh/sshd_config.tmp /etc/ssh/sshd_config |
sed -i 's/PermitRootLogin yes/PermitRootLogin without-password/' /etc/ssh/sshd_config # Allow TZ variable sed -i 's/AcceptEnv LANG LC_\*$/AcceptEnv LANG LC_\* TZ/' /etc/ssh/sshd_config |
Line 40: | Line 41: |
moreutils \ | less moreutils \ mosh \ |
Line 42: | Line 44: |
chrony \ vim less \ |
vim vim-pathogen vim-addon-manager vim-scripts \ |
Line 49: | Line 50: |
cpufrequtils powertop \ | |
Line 52: | Line 52: |
# Enable automatic security updates (careful!) (TODO: this is interactive; how to pass "yes"?) sudo dpkg-reconfigure -plow unattended-upgrades |
# Optional stuff… sudo aptitude install \ chrony \ cpufrequtils powertop # Ensure enough entropy is always available sudo aptitude install \ haveged rng-tools # I hate rm sudo aptitude install \ trash-cli # Reduce bufferbloat echo 'net.core.default_qdisc=fq_codel' > /etc/sysctl.d/reduce-bufferbloat.conf # Enable automatic security updates (careful!) sudo DEBIAN_FRONTEND=noninteractive dpkg-reconfigure -plow unattended-upgrades |
Line 91: | Line 107: |
# Add noatime,commit=900 to entries in /etc/fstab # Enable SATA ALPM echo SATA_ALPM_ENABLE=true | sudo tee /etc/pm/config.d/sata_alpm # Switch to systemd sudo aptitude install systemd-sysv libpam-systemd |
|
Line 92: | Line 116: |
Other sources: https://feeding.cloud.geek.nz/posts/usual-server-setup/ == New account setup == === Remote === {{{#!highlight sh # Quiet login touch .hushlogin cd ~ mkdir -p .ssh/controls mkdir -p .vim/tmp chmod -R 755 .ssh chmod 644 .ssh/authorized_keys }}} === Locally === {{{#!highlight sh # Setup dot files mkdir -p ~/src/git.other/ cd ~/src/git.other/ git clone https://github.com/samatjain/dotfiles.git cd dotfiles source init-dots dots groups set base # Set addtl groups as necessary dots install }}} === Raspberry Pi stuff === {{{#!highlight sh # Switch from wheezy to testing cd /etc/apt/ sed -i 's/wheezy/testing/g' /etc/apt/sources.list #sudo find . -type f -exec sed -i 's/wheezy/testing/g' {} \; # Disable tty2–tty6 sed -i '/[2-6]:23:respawn:\/sbin\/getty 38400 tty[2-6]/s%^%#%g' /etc/inittab # Disable tty on serial line sed -i '/T0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100/s%^%#%g' /etc/inittab # Optimize mounts sed -i 's/defaults,noatime/defaults,noatime,nodiratime/g' /etc/fstab # Overclock to 800 Mhz (no overvolting required). Overclocking not forced, but keep it on for the first 2 min during boot echo -e "arm_freq=800\nsdram_freq=400\ncore_freq=300\nforce_turbo=0\ninitial_turbo=120" >> /boot/config.txt # Use only 16 MiB for GPU (only run after updating firmware!) echo -e "gpu_mem=16" >> /boot/config.txt # Enable IPv6 for Avahi sudo sed -i 's/mdns4_minimal/mdns_minimal/g' /etc/nsswitch.conf # Delete default 'pi' user sudo deluser --remove-all-files pi }}} Some of these are from [[https://extremeshok.com/1081/raspberry-pi-raspbian-tuning-optimising-optimizing-for-reduced-memory-usage/|Raspberry Pi Raspbian tuning / optimising / optimizing for reduced memory usage]] |
Chris Lamb has a good Debian installation checklist, from which I stole most of this list.
1 # Configure sudo, adding my user to the sudo group so I don't get password prompts
2 aptitude install sudo
3 adduser xjjk sudo
4 echo '%sudo ALL=NOPASSWD: ALL' > /etc/sudoers.d/No-Passwords-for-sudo-Group
5 chmod 0440 /etc/sudoers.d/No-Passwords-for-sudo-Group
6
7 # Disable installation of recommended packages
8 echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/90recommends
9
10 # Configure locales to prevent harassment about it later
11 aptitude install locales
12 dpkg-reconfigure -plow locales
13 # …or install all locales so they don't need to be configured/reinstalled
14 aptitude install locales-all
15
16 # Enable log compression with date suffixed extension
17 cat /etc/logrotate.conf | sed "s/#compress/compress\ndateext/" > /etc/logrotate.conf.tmp
18 mv /etc/logrotate.conf.tmp /etc/logrotate.conf
19
20 # Disable root login—public key access only!
21 sed -i 's/PermitRootLogin yes/PermitRootLogin without-password/' /etc/ssh/sshd_config
22 # Allow TZ variable
23 sed -i 's/AcceptEnv LANG LC_\*$/AcceptEnv LANG LC_\* TZ/' /etc/ssh/sshd_config
24 service ssh restart
25
26 # Prevent PAM from allowing easily-crackable passwords
27 aptitude install libpam-cracklib
28
29 # Install essential utilities
30 sudo aptitude install \
31 openssh-server screen \
32 rsync \
33 atool lzma rzip xz-utils \
34 htop dstat iotop \
35 manpages manpages-dev \
36 strace tcpdump lsof \
37 less moreutils \
38 mosh \
39 dnsutils \
40 vim vim-pathogen vim-addon-manager vim-scripts \
41 bash-completion \
42 sysfsutils procps \
43 vnstat \
44 unattended-upgrades \
45 ncurses-term \
46 molly-guard
47
48 # Optional stuff…
49 sudo aptitude install \
50 chrony \
51 cpufrequtils powertop
52
53 # Ensure enough entropy is always available
54 sudo aptitude install \
55 haveged rng-tools
56
57 # I hate rm
58 sudo aptitude install \
59 trash-cli
60
61 # Reduce bufferbloat
62 echo 'net.core.default_qdisc=fq_codel' > /etc/sysctl.d/reduce-bufferbloat.conf
63
64 # Enable automatic security updates (careful!)
65 sudo DEBIAN_FRONTEND=noninteractive dpkg-reconfigure -plow unattended-upgrades
66
67 # HDD Temperature/SMART monitoring utilities
68 aptitude install hddtemp smartmontools
69 sed -i 's/^#start_smartd=yes/start_smartd=yes/' /etc/default/smartmontools
70 /etc/init.d/smartmontools start
71
72 # Configure rsyslog for daily archival logging
73 cat << EOF > /etc/rsyslog.d/51-cron.conf
74 # Enable cron logging
75 cron.* /var/log/cron.log
76 EOF
77 cat << EOF > /etc/rsyslog.d/99-archive.conf
78 \$template DailyLogs,"/var/log/archive/%\$YEAR%%\$MONTH%/%\$YEAR%%\$MONTH%%\$DAY%.log"
79 # Archive logging
80 *.* -?DailyLogs
81 EOF
82 cat << EOF > /etc/cron.daily/rsyslog-archive
83 #!/bin/sh
84 # Compress *.log-files not changed in more than 24 hours
85 find /var/log/archive -type f -mtime +1 -name "*.log" -exec xz '{}' \;
86 EOF
87 chmod +x /etc/cron.daily/rsyslog-archive
88
89 # Async logging for rsync (commit every 30m)
90 cat << EOF > /etc/rsyslog.d/98-async.conf
91 \$OMFileFlushInterval 1800
92 \$OMFileASyncWriting on
93 EOF
94
95 # Use tmpfs for /var/run and /var/lock (may break some buggy packages), like Ubuntu
96 cat << EOF >> /etc/default/rcS
97 RAMRUN=yes
98 RAMLOCK=yes
99 EOF
100
101 # Allow running X11 apps remotely
102 sudo aptitude install xbase-clients
103
104 # Add noatime,commit=900 to entries in /etc/fstab
105
106 # Enable SATA ALPM
107 echo SATA_ALPM_ENABLE=true | sudo tee /etc/pm/config.d/sata_alpm
108
109 # Switch to systemd
110 sudo aptitude install systemd-sysv libpam-systemd
Other sources:
https://feeding.cloud.geek.nz/posts/usual-server-setup/
New account setup
Remote
Locally
Raspberry Pi stuff
1 # Switch from wheezy to testing
2 cd /etc/apt/
3 sed -i 's/wheezy/testing/g' /etc/apt/sources.list
4 #sudo find . -type f -exec sed -i 's/wheezy/testing/g' {} \;
5
6 # Disable tty2–tty6
7 sed -i '/[2-6]:23:respawn:\/sbin\/getty 38400 tty[2-6]/s%^%#%g' /etc/inittab
8 # Disable tty on serial line
9 sed -i '/T0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100/s%^%#%g' /etc/inittab
10
11 # Optimize mounts
12 sed -i 's/defaults,noatime/defaults,noatime,nodiratime/g' /etc/fstab
13
14 # Overclock to 800 Mhz (no overvolting required). Overclocking not forced, but keep it on for the first 2 min during boot
15 echo -e "arm_freq=800\nsdram_freq=400\ncore_freq=300\nforce_turbo=0\ninitial_turbo=120" >> /boot/config.txt
16
17 # Use only 16 MiB for GPU (only run after updating firmware!)
18 echo -e "gpu_mem=16" >> /boot/config.txt
19
20 # Enable IPv6 for Avahi
21 sudo sed -i 's/mdns4_minimal/mdns_minimal/g' /etc/nsswitch.conf
22
23 # Delete default 'pi' user
24 sudo deluser --remove-all-files pi
Some of these are from Raspberry Pi Raspbian tuning / optimising / optimizing for reduced memory usage