Most Powerful Open Source ERP

如何准备树莓派以用于远程维护

设置树莓派来让 Rapid.Space 团队将其作为远程维护工具。
  • Last Update:2020-06-03
  • Version:001
  • Language:zh

准备树莓派作为远程维护工具

 

背景

RapidSpace 硬件提供者需要在服务器上进行维护工作,并需要获得 Rapid.Space 团队的帮助。这种情况下需要提供一个可供 Rapid.Space 团队访问的树莓派设备。这个树莓派需要通过手机热点联网,Rapid.Space 团队将会用 re6st 访问树莓派。

 

如何设置树莓派

auto eth0
iface eth0 inet static
  address 192.168.46.2
  netmask 24

# setup of Wifi connection, make sure to use the parameter from your phone
auto wlan0
iface wlan0 inet dhcp
        wpa-ssid yourwifiname
        wpa-psk yourpassword
  • 安装 Freefib re6st (用 root 运行下面的命令)
wget https://deploy.erp5.net/gnet/re6st # in China, you can use "wget https://deploy.erp5.cn/gnet/re6st"

# make sure to have requested a token (see vifib-HowTo.Request.Freefib.Re6st.Token)
FORCE=yes bash re6st

# you will need to insert your token and chose if you want router advertisement
  • 安装 openssh-server
sudo apt install openssh-server
sudo systemctl start ssh
sudo systemctl enable ssh
  • 在 pi 用户下设置 Rapid.Space 团队的 ssh 密钥(在 pi 用户下运行下列命令)
cat >> ~/.ssh/authorized_keys << EOF
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5qVcd6gclQmxL9i0Vsasy6vMiVaIjKHHNAwVBRjx0Ie+sDxaCZRJHrRGJmbDMMJBSV2vO08DgureHdDkXoLpR4M7LjgjPW/gAP3nQ9w0b8L1VixXvXiIDWIdgeD+beHrMJyZM0cbEWN1nGL0eMP8C9PWIZDvxPvAGDwW1uSDKdBtfQuLTcByWQa0IP9I/tJaC5gov8IOdWS6x7pqZW29SYoRd0HOQJfODoq8lFhtCrpMbzgXEaXTglSTXPI92URqSAqY2WXW1Aqm3baZSU5eM9HfU7a6OYC8RQ0Lywxw276uHRribLSPZelWO+HiIEu7jQ3VUIe0bXu5tgcMsuswd luke@nexedi.com-chronos

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5MAMmMmojqNRoOnGc7xGoJWWAzYo2f2zO2K4elsZhHfG6l2SQJTmna0DuUi8qEtBbA9+TN1HAOeEXQKMsQyydG8dAE9vT41Lj5y8kXQDDquQxcpTIrqjmSqxjG42Olk+sT+XvcdyqA//29OHhhrKdhIf9LAOsIPHDYW06hRMf7kXIgt3MNi8ayPpA9coTHIscvV8MzwbF2q8Owrkj5UpPmSd/cjmFTcijT3rXmN0E1d3lrCvIuqxFBsFB47o0q53rFZMc5HoHQjJbg6dB4E0GNT0Ujl9ZaIDEzQbe1/T5BVWXrwDfYXbj8UlqtXeFQlo2dB+au2tHw56s4boqDxIl thomas.gambier@nexedi.com
EOF
  • 将 IPv6 地址发给 Rapid.Space 团队(运行命令”ip -6 address“并将结果发送给 Rapid.Space 团队),让他们测试

 

可选:安装 PXE 启动服务器

这一步是可选的,只有 Rapid.Space 要求的时候再这么做。

  • 用 SSH 登录树莓派并运行下面的代码:
#!/bin/bash

apt install -y dnsmasq

cat << EOF > /etc/dnsmasq.conf
port=0
interface=eth0
dhcp-range=192.168.46.51,192.168.46.150,12h
dhcp-option=3,192.168.46.1
dhcp-option=vendor:Etherboot,60,"Etherboot"
dhcp-boot=grubx64.efi
enable-tftp
tftp-root=/tftpboot/debian10
tftp-secure
log-dhcp
EOF

# create Debian 10 boot directory
mkdir -p /tftpboot/debian10
cd /tftpboot/debian10
wget http://ftp.debian.org/debian/dists/buster/main/installer-amd64/current/images/netboot/netboot.tar.gz
tar -xzvf netboot.tar.gz
ln -s debian-installer/amd64/grubx64.efi 


chown -R dnsmasq: /tftpboot/

systemctl restart dnsmasq
systemctl enable dnsmasq

 

按需调整网络

如果交换机地址不是 192.168.46.1,那么需要调整下面两个:

  • 登录树莓派,用户名为 pi,密码为 nexedi
  • 编辑 /etc/network/interfaces ,修改地址和网关地址
  • 编辑 /etc/dnsmasq.conf ,修改 dhcp-range 和 dhcp-option=3 这两行