树莓派鼓捣记

树莓派是自带有无线网卡的,所以可以连接 wifi。

本文的树莓派系统环境是 Ubuntu Server 20.04,其他 Linux 系统都大同小异。

ssh 进入树莓派。

1.第一步设置时区

sudo tzselect

# 选择4 Aisa

# 然后选择9 China

# 接着选择1 Beijing Time

# 最后选择1 确认

sudo cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

设置完成后执行 date -R 看时间是否准确。

2.设置 wifi

cd /etc/netplan/
sudo vim 50-cloud-init.yaml

打开后应该会有以下内容:

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2

现在需要加一个wifi的配置,示例如下:

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    wifis:
        wlan0:
            dhcp4: true
            access-points:
                <wifi名字>:
                    password: "<wifi密码>"
    version: 2

编辑完成后保存,然后执行命令

sudo netplan --debug apply

3.检查设置

执行命令 ifconfig 检查是否有网卡 wlan0 的信息,并且获取到了ip,最后通过这个ip进行 ssh 连接,如果连接成功,那就没有问题了。

原文地址:https://www.cnblogs.com/stulzq/p/13951431.html