OS のインストール

プリインストールイメージの準備

http://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/

SDカードへ書き込み

https://www.balena.io/etcher/

起動時IP アドレスの確認

fing やルータでIP アドレスを確認して接続。

$ ssh ubuntu@192.168.11.26

OS の設定

ホストネームの設定

$ sudo hostnamectl set-hostname pi4

IP アドレスの固定化

/etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: no
optional: no
addresses:
- 192.168.11.26/24
gateway4: 192.168.11.1
nameservers:
addresses:
- 192.168.11.1
$ sudo netplan apply

Alias 等の設定

  • Alias
    ~/.bash_aliases
    # Update installed packages
    alias upd='sudo apt update -y && sudo apt dist-upgrade && sudo apt autoremove -y'

    # Change locale
    alias en='export LC_ALL=en_US.UTF8'
    alias ja='export LC_ALL=ja_JP.UTF8'

    # ssh to remote host in local network
    function sshu() {
    command ssh ubuntu@192.168.11.$1
    }
    $ . ~/.bash_aliases

パッケージ更新

$ upd

Docker

Docker-CE

$ curl -fsSL https://get.docker.com/ | sh
/etc/apt/sources.list.d/docker.list
deb [arch=amd64] https://download.docker.com/linux/ubuntu disco stable
$ sudo apt update
$ sudo apt install docker-ce
$ sudo usermod -aG docker $USER
$ docker --version
Docker version 19.03.1, build 74b1e89
$ sudo reboot

Docker Compose

$ sudo apt isntall docker-compose
$ docker-compose --version
docker-compose version 1.21.0, build unknown

Portainer

  • docker-compose.yml
    ./docker-portainer/docker-compose.yml
    version: '2'
    services:
    portainer:
    restart: always
    image: portainer/portainer
    container_name: portainer
    ports:
    - "9000:9000"
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - ./data:/data
  • 起動
    $ cd docker-portainer
    $ docker-compose up -d
  • アクセス
    http://192.168.11.26:9000/
    admin に8文字以上のパスワードを設定

Samba

ディスクの確認

$ lsblk -f
/etc/fstab
LABEL=media03 /mnt/media03 ext2 defaults 0 0
LABEL=media04 /mnt/media04 ext4 defaults 0 0
$ sudo mount -a

Samba の設定

$ sudo apt install samba
/etc/samba/smb.conf
[global]
unix charset = UTF-8
dos charset = CP932

interfaces = 127.0.0.0/8 192.168.11.0/24

bind interfaces only = yes
map to guest = Bad User

[media03]
path = /mnt/media03
writable = yes
guest ok = yes
guest only = yes
create mode = 0777
directory mode = 0777

[media04]
path = /mnt/media04
writable = yes
guest ok = yes
guest only = yes
create mode = 0777
directory mode = 0777

VPN

Pritunl

https://ktkr3d.github.io/2019/08/17/Pritunl/