目錄 顯示
我在樹莓派上跑 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