45行目: | 45行目: | ||
# systemctl stop [service] | # systemctl stop [service] | ||
# systemctl disable [service] | # systemctl disable [service] | ||
Debian11では以下27個のサービスたちがデフォルトで稼働している | |||
{| class="wikitable" summary="稼働しているサービス(RH系)" | |||
|- | |||
!alsa-restore | |||
|(exited) Save/Restore Sound Card device driver | |||
|- | |||
!avahi-daemon | |||
|(running) Avahi mDNS/DNS-SD Stack | |||
|- | |||
!bluetooth | |||
|(running) Bluetooth service | |||
|- | |||
!console-setup | |||
|(exited) Set console font and keymap | |||
|- | |||
!cron | |||
|(running) Regular background program | |||
|- | |||
!dbus | |||
|(running) D-Bus System Message Bus | |||
|- | |||
!dhcpcd | |||
|(running*) dhcpcd on all interfaces | |||
|- | |||
!dphys-swapfile | |||
|(exited) LSB: Autogenerate and use | |||
|- | |||
!fake-hwclock | |||
|(exited) Restore / save the curren | |||
|- | |||
!getty@tty1 | |||
|(running) Getty on tty1 | |||
|- | |||
!hciuart | |||
|(running) Configure Bluetooth Modem | |||
|- | |||
!keyboard-setup | |||
|(exited) Set the console keyboard | |||
|- | |||
!kmod-static-nodes | |||
|(exited) Create list of required | |||
|- | |||
!networking | |||
|(exited) Raise network interfaces | |||
|- | |||
!raspi-config | |||
|(exited) LSB: Switch to ondemand configuration | |||
|- | |||
!rc-local | |||
|(exited) /etc/rc.local Compatibiliy | |||
|- | |||
!rsyslog | |||
|(running) System Logging Service | |||
|- | |||
!systemd-fsck-root | |||
|(exited) File System Check on Root | |||
|- | |||
!systemd-fsck@dev-disk-by\ | |||
|(exited) File System Check on | |||
|- | |||
!systemd-fsckd | |||
|(running) File System Check Daemon | |||
|- | |||
!systemd-hostnamed | |||
|(running) Hostname Service | |||
|- | |||
!systemd-journal-flush | |||
|(exited) Flush Journal to Persisted | |||
|- | |||
!systemd-journald | |||
|(running) Journal Service | |||
|- | |||
!systemd-logind | |||
|(running) Login Service | |||
|- | |||
!systemd-modules-load | |||
|(exited) Load Kernel Modules | |||
|- | |||
!systemd-random-seed | |||
|(exited) Load/Save Random Seed | |||
|- | |||
!systemd-remount-fs | |||
|(exited) Remount Root and Kernel File system | |||
|- | |||
!systemd-sysctl | |||
|(exited) Apply Kernel Variables | |||
|- | |||
!systemd-timesyncd | |||
|(running) Network Time Synchronizatate | |||
|- | |||
!systemd-tmpfiles-setup-dev | |||
|(exited) Create Static Device Node | |||
|- | |||
!systemd-tmpfiles-setup | |||
|(exited) Create Volatile Files and | |||
|- | |||
!systemd-udev-trigger | |||
|(exited) udev Coldplug all Devices | |||
|- | |||
!systemd-udevd | |||
|(running) udev Kernel Device Manage | |||
|- | |||
!systemd-update-utmp | |||
|(exited) Update UTMP about System | |||
|- | |||
!systemd-user-sessions | |||
|(exited) Permit User Sessions | |||
|- | |||
!triggerhappy | |||
|(running) triggerhappy global hotkey | |||
|- | |||
!user@1000 | |||
|(running) User Manager for UID 1000 | |||
|} | |||
* 起動サービスの確認と停止。セキュリティを考慮して使わないサービスは停止、自動起動も無効にする | * 起動サービスの確認と停止。セキュリティを考慮して使わないサービスは停止、自動起動も無効にする |
2022年11月28日 (月) 17:08時点における版

Debian の「全て」を理解してまとめておく。
セットアップ
- Debian はインストール時に root と一般ユーザが登録される
- sudoコマンドがないので「su -」で root になって操作する。root が馴染み深くなる
環境設定
$ cat /etc/debian_version $ vi .bash_aliases alias ls='ls -lh --color=auto' alias less='less -N' $ . ~/.bash_aliases
SSH接続
[港] $ systemctl status sshd $ ss -tan # vi /etc/ssh/sshd_config Port 55555 # systemctl sshd restart $ ss -tan $ lsof -i:55555 # ls /etc/ssh $ ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub # vi /etc/ssh/sshd_config PasswordAuthentication no $ cat ~/.ssh/authorized_keys
[領内] $ ssh-keygen -t ed25519 $ vi ~/.ssh/config HOST hoge HostName moge.vs.sakura.ne.jp Port 55555 $ ssh-copy-id hoge $ ssh-add $ ssh-add -l $ ssh hoge
セキュアなサーバ設定
サービスの採用/不採用
# systemctl -t service | grep running # systemctl stop [service] # systemctl disable [service]
Debian11では以下27個のサービスたちがデフォルトで稼働している
alsa-restore | (exited) Save/Restore Sound Card device driver |
---|---|
avahi-daemon | (running) Avahi mDNS/DNS-SD Stack |
bluetooth | (running) Bluetooth service |
console-setup | (exited) Set console font and keymap |
cron | (running) Regular background program |
dbus | (running) D-Bus System Message Bus |
dhcpcd | (running*) dhcpcd on all interfaces |
dphys-swapfile | (exited) LSB: Autogenerate and use |
fake-hwclock | (exited) Restore / save the curren |
getty@tty1 | (running) Getty on tty1 |
hciuart | (running) Configure Bluetooth Modem |
keyboard-setup | (exited) Set the console keyboard |
kmod-static-nodes | (exited) Create list of required |
networking | (exited) Raise network interfaces |
raspi-config | (exited) LSB: Switch to ondemand configuration |
rc-local | (exited) /etc/rc.local Compatibiliy |
rsyslog | (running) System Logging Service |
systemd-fsck-root | (exited) File System Check on Root |
systemd-fsck@dev-disk-by\ | (exited) File System Check on |
systemd-fsckd | (running) File System Check Daemon |
systemd-hostnamed | (running) Hostname Service |
systemd-journal-flush | (exited) Flush Journal to Persisted |
systemd-journald | (running) Journal Service |
systemd-logind | (running) Login Service |
systemd-modules-load | (exited) Load Kernel Modules |
systemd-random-seed | (exited) Load/Save Random Seed |
systemd-remount-fs | (exited) Remount Root and Kernel File system |
systemd-sysctl | (exited) Apply Kernel Variables |
systemd-timesyncd | (running) Network Time Synchronizatate |
systemd-tmpfiles-setup-dev | (exited) Create Static Device Node |
systemd-tmpfiles-setup | (exited) Create Volatile Files and |
systemd-udev-trigger | (exited) udev Coldplug all Devices |
systemd-udevd | (running) udev Kernel Device Manage |
systemd-update-utmp | (exited) Update UTMP about System |
systemd-user-sessions | (exited) Permit User Sessions |
triggerhappy | (running) triggerhappy global hotkey |
user@1000 | (running) User Manager for UID 1000 |
- 起動サービスの確認と停止。セキュリティを考慮して使わないサービスは停止、自動起動も無効にする
- 「running」は常に戦闘モードな状態。一方「exited」は休んでいる状態
- デフォルトで 稼働しているサービス(Debian系)
- デフォルトで 稼働しているサービス(RH系)
- 不要なサービスは脆弱性の元なので全て停止する。ランレベル3(CUIモード)で自動起動するサービスを確認して停止、自動起動をオフにする
# chkconfig --list | grep 3:on # service auditd stop # service netfs stop auditd(コマンド監視), ip6tables(IP6利用), netfs(NFSクライアント), postfix(SMTPサーバ利用)
- メールサーバなど、ユーザアカウントは必要だけどシェルログインは不要なユーザは、ログインシェルを「/sbin/nologin」か「/bin/false」にする
#useradd -s /sbin/nologin march #usermod -s /sbin/nologin march
パッケージ管理
- 全てのパッケージを最新のものにアップデートしてシステムを最新の状態にする
$ apt list --installed # apt update # apt upgrade # apt full-upgrade
- ソフトウェアパッケージのアップデートを自動化する。そのためにも、ソフトは基本的にapt等パッケージ管理システムからインストールする
# apt install cron-apt ← vi /etc/cron-apt/config(アプデ自動化) # timedatectl status # timedatectl set-timezone Asia/Tokyo # date
- ユーザがディスクの空き容量を使い切ってしまわないように、ユーザが利用するファイルシステムには独立したパーティションを割り当てる
- 変更されないデータを格納するファイルシステムは、リードオンリーでマウントすることによりファイルの改竄や破壊行為を抑えられる
- アドレススキャン(港探索)回避のためにブロードキャスト宛リクエストを無視する。下記の設定ファイルに追記
/etc/sysctl.conf net.ipv4.icmp_echo_ignore_broadcast=1