我在树莓派上跑 ubuntu + docker 同步文件有一段时间了, 期间报错无数, 停机无数, 偶有出现cpu占用到100%, 以为是被攻击, 然后发现是 snapd 的bug.
也许 ubuntu 就是不适合做家用服务器?
所以有了下面这一篇文章, 纪录一下我的快速配置.
下载 Centos8 stream arch64 for pi
Copy连接下载
下载树莓派官方刷机工具
点击官网下载
刷入机器, ssh 连结.
- 默认帐户:
root
- 默认密码:
centos
基础配置
# 扩展瓷盘 rootfs-expand # 设置时间并开启自动同步 # 你可能想要自己配置 ntp 服务器 # vi /etc/chrony.conf # server s1a.time.edu.cn iburst # server ntp.aliyun.com iburst systemctl enable chronyd.service systemctl restart chronyd.service timedatectl set-timezone Asia/Shanghai timedatectl set-ntp true echo '@reboot timedatectl set-ntp true' >> /etc/crontab timedatectl # 安装扩展库 yum install epel-release -y yum update -y # 安装基础工具 yum install vim git make ufw -y # 设置防火墙 ufw allow from 192.168.10.1/24 # ufw allow ssh ufw default deny ufw enable ufw status # 将多余的配置删掉 # 设置网路 nmtui
那么, 基础设置已经完成了, ufw 已经配置只允许局域网访问的缘故, 怕烦不设自定义密码也是可以的.
登陆配置
# 更改默认 root 密码 passwd root # 配置 ssh 连结 cd ~/ mkdir .ssh chmod 700 .ssh vi /root/.ssh/authorized_keys chmod 644 /root/.ssh/authorized_keys # 将你的公钥复制进去 vi /etc/ssh/sshd_config # 配置ssh登录
在 sshd_config
中分别修改下面几句
LoginGraceTime 10m #afk达10min自动登出 PermitRootLogin prohibit-password #只允许root用ssh登录 MaxAuthTries 6 #最多允许三次错误登录尝试 MaxSessions 10 #最多允许三个client同时登录 PubkeyAuthentication yes #开启公钥登录 AuthorizedKeysFile .ssh/authorized_keys #开启公钥 PasswordAuthentication no #不允许任何用户使用密码登录 PermitEmptyPasswords no #不允许任何空密码用户登录
systemctl restart sshd.service systemctl status sshd.service # 确认 status 没问题 exit # 现在请重新登陆
我自己的设置 备忘
# 开机挂载网络硬盘 @reboot curlftpfs -o rw,allow_other ftp://username:[email protected]/ /media/ftpdrive # 开机挂载硬盘 # 卸载一定要 umount, rm 挂载点会删掉你所有文件, 切记! mkdir /media/backup mount /dev/sda1 /media/backup blkid # 复制显示的 uuid 和 瓷盘类型 echo 'UUID=cc01ef19-892e-4eaf-862a-4f7b9cab3c0f /media/backup ext4 defaults 1 2' >> /etc/fstab mount -a # 非常重要! 有报错不解决 下次开不了机 # 安装宝塔 cd /tmp curl -sSO http://download.bt.cn/install/install_panel.sh && bash install_panel.sh y