树莓派 操作记录

1. 更换源

运行 lsb_release -c,查看对应版本,我的为buster。

运行 sudo nano /etc/apt/sources.list,增加中科大和阿里的镜像。

deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main non-free contrib
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi

运行 sudo apt-get update,更新索引

运行 sudo apt-get upgrade,更新软件

运行 sudo apt-get dist-upgrade,

2. SSH Connection closed by foreign host

  1. 修改该文件 /etc/ssh/sshd_config
  2. ClientAliveInterval 60
    ClientAliveCountMax 3
  3. 重启SSH服务,
    /etc/init.d/ssh restart
    systemctl restart sshd

这个问题最初是在使用 sudo apt-get upgrade 时,ssh断开连接。

解决方法:使用GNU屏幕。屏幕提供了一个虚拟终端,即使您的ssh连接丢失,该终端也可以继续运行。

sudo apt-get install screen,安装屏幕

screen,启动屏幕

ctrl+a+d,暂时离开screen,

screen r,重新连接screen

3. 更改时区

date,查看当前系统时间

sudo dpkg-reconfigure tzdata,选择Asia,Shanghai

4. 安装vim

sudo apt-get install vim

配置参考 https://www.francis67.cc/archives/51

5. 使用windows 远程桌面连接

sudo apt-get install xrdp,安装xdrp服务

使用windows自带的远程桌面连接即可登录。(前提是安装了
Raspberry Pi OS (32-bit) with desktop,其中包括桌面软件)

6. frp

使用命令行下载并解压frp最新版本

wget https://github.com/fatedier/frp/releases/download/v0.34.0/frp_0.34.0_linux_amd.tar.gz
tar -zxvf frp_0.34.0_linux_amd.tar.gz
cd frp_0.34.0_linux_amd
修改客户端配置 frpc.ini,可参考https://blog.francis67.cc/archives/537

[common]为具有公网IP的VPS的配置,同时为树莓派增加了[SSH]连接

通过 frpc -c /etc/frpc.ini 启动,并使用systemctl将frp添加到服务实现开机自启动。

sudo vim /lib/systemd/system/frps.service

[Unit]
Description=frps service

[Service]
Type=simple
Restart=always
RestartSec=20s
# specific file path
ExecStart=/xxx/frpc -c /xxx/frpc.ini
ExecStop=/bin/kill $MAINPID

[Install]
WantedBy=multi-user.target

使用 sudo systemctl start frps 启动服务,并添加下次重启自启动 sudo systemctl enable frps

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注