1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Proxmoxで自宅サーバーを強化!Samba×Syncthingで快適ファイル共有!

Last updated at Posted at 2025-09-19

前提

  • Proxmox VE 9.0.9
  • Fedora Server 42

はじめに

本記事では、Proxmox上で動作するFedoraを使用し、ポータブルSSDを活用した快適なファイル同期環境の構築方法をご紹介します。

ファイル共有にはSambaとSyncthingを使用しています。ポータブルSSDを共有先として利用する目的は、必要なときに取り外してWindows環境でもデータを確認するためです。

Fedora Server 42をダウンロード

下記のリンクからFedora Server 42のISOをダウンロードする。

ProxmoxにISOをアップロード

UploadからISOファイルをアップロードする。
image.png

Proxmoxで仮想マシン(VM)を作成

Proxmox VEのWEB GUIの右上にあるCreate VMを押下し設定を進めていきます。

Generalタブ

Nameを設定する。
image.png

OSタブ

ISO imageにFedora Server 42を選択する。
image.png

Systemタブ

Machineにq35を指定し、BIOSにOVMF(UEFI)を指定する。
image.png

Disksタブ

基本的にデフォルトのままでOKです。私はDisk sizeを32GiBから16GiBに変更しました。
image.png

CPUタブ

基本的にデフォルトのままでOKです。私はCoresを1から2に変更しました。
image.png

Memoryタブ

Ballooning Deviceのチェックをオフにします。
image.png

Networkタブ

基本的にデフォルトのままでOKです。
image.png

Confirmタブ

設定内容を確認し、右下のFinishボタンを押下してください。
image.png

Fedoraのインストール

作成した仮想マシン(VM)を選択し、右上にある▶ Startボタンを押下する。
Consoleメニューから設定を進めることができます。
image.png

ネットワークとホスト名

ネットワークとホスト名から固定IPアドレスにする。
image.png

ユーザーの作成

ユーザーを作成する。rootアカウントは無効のままとする。
image.png

インストール概要

設定完了後に、インストールの開始(B)のボタンを押下する。
image.png

Fedoraの設定

パッケージの更新

sudo dnf upgrade -y

SSHの設定

/etc/ssh/sshd_config
# ---------------------
#  SSH 設定ファイル
# ---------------------

# 追加設定ファイルの指定
# Include /etc/ssh/sshd_config.d/*.conf

# サーバーのポートを指定
Port 22

# サーバーが待機するIPを指定
AddressFamily inet
ListenAddress 0.0.0.0

# 特定のユーザーだけ許可
AllowUsers secureuser {ユーザ名}

# Root ユーザーのログインを無効化
PermitRootLogin no

# 空パスワードを禁止
PermitEmptyPasswords no

# パスワード認証を無効化
# PasswordAuthentication no

# 公開鍵認証のみ許可
# PubkeyAuthentication yes

# 公開鍵認証の種類をED25519のみに限定する
HostKey /etc/ssh/ssh_host_ed25519_key

# 安全なアルゴリズムのみ許可する
KexAlgorithms curve25519-sha256@libssh.org
Ciphers chacha20-poly1305@openssh.com
MACs hmac-sha2-512-etm@openssh.com

# 逆引きDNSを無効化
UseDNS no

# ユーザーセッションのタイムアウト
ClientAliveInterval 300 # 5分間操作なしの場合接続切断
ClientAliveCountMax 0

# 接続失敗に対する制限
MaxAuthTries 3 # 最大3回の認証試行
MaxSessions 1  # 同時セッション数の制限

# バージョンの制限
Protocol 2

# 安全なタイムスタンプを強制
UsePAM yes

# ログインのグレース期間を設定
LoginGraceTime 20

# 転送・トンネリングを無効化
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
PermitTunnel no

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

# SFTPを有効にする
# Subsystem     sftp    /usr/lib/openssh/sftp-server

{ユーザ名}はSSHでログインするものに変更してください。

SSHの設定ファイルのチェックを実施

sudo sshd -t

Firewalldの設定

# カスタムゾーンの作成
sudo firewall-cmd --permanent --new-zone=custom
sudo firewall-cmd --reload

# SSH、Samba、cockpit、Syncthingを許可
sudo firewall-cmd --permanent --zone=custom --add-rich-rule='rule family=ipv4 source address="192.168.0.0/16" port protocol="tcp" port="22" accept'
sudo firewall-cmd --permanent --zone=custom --add-rich-rule='rule family=ipv4 source address="192.168.0.0/16" port protocol="tcp" port="445" accept'
sudo firewall-cmd --permanent --zone=custom --add-rich-rule='rule family=ipv4 source address="192.168.0.0/16" port protocol="tcp" port="8384" accept'
sudo firewall-cmd --permanent --zone=custom --add-rich-rule='rule family=ipv4 source address="192.168.0.0/16" port protocol="tcp" port="9090" accept'
sudo firewall-cmd --permanent --zone=custom --add-rich-rule='rule family=ipv4 source address="192.168.0.0/16" port protocol="tcp" port="22000" accept'

# デフォルトゾーンの設定
sudo firewall-cmd --set-default-zone=custom
sudo firewall-cmd --reload

# ルールを確認
sudo firewall-cmd --list-all

自動更新の設定

dnf-automatic パッケージをインストール

sudo dnf install dnf-automatic -y

dnf-automatic 設定ファイル作成

shell /etc/dnf/automatic.conf
apply_updates = yes
download_updates = yes
upgrade_type = default

サービスを有効にする

sudo systemctl enable --now dnf-automatic.timer

以下の設定は、任意設定になります。

Kernelの設定

/etc/sysctl.d/90-hardening.conf
# カーネルポインタ制限
kernel.kptr_restrict=2

# ASLR(アドレス空間配置のランダム化)を強制
kernel.randomize_va_space=2

# dmesg出力制限
kernel.dmesg_restrict=1

# 非特権BPF無効
kernel.unprivileged_bpf_disabled=1

# ptrace制限
kernel.yama.ptrace_scope=2

# 非特権ユーザ名前空間の無効化
kernel.unprivileged_userns_clone=0

# BPF JIT強化
net.core.bpf_jit_harden=2

# SYNクッキー有効
net.ipv4.tcp_syncookies=1

# IPv4 rp_filter有効
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.accept_redirects=0
net.ipv4.conf.default.accept_redirects=0
net.ipv4.conf.all.secure_redirects=0
net.ipv4.conf.default.secure_redirects=0

# IPv4送信リダイレクト無効
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.default.send_redirects=0

# IPv4ソースルート無効
net.ipv4.conf.all.accept_source_route=0
net.ipv4.conf.default.accept_source_route=0

# IPv6を無効
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

# mmap ASLR強化
vm.mmap_rnd_bits=32
vm.mmap_rnd_compat_bits=16

# シンボリック/ハードリンク保護
fs.protected_symlinks=1
fs.protected_hardlinks=1

# FIFO/通常ファイル保護
fs.protected_fifos=2
fs.protected_regular=2

設定内容の反映

sudo sysctl -p

カーネルの起動オプションに以下を追加

/etc/default/grub
# カーネル起動時に適用するオプションを指定
# quiet                : ブート時の出力を抑制
# slab_nomerge         : スラブアロケータの統合機能を無効にする
# init_on_alloc=1      : メモリアロケーション時にゼロ初期化を行う(セキュリティ向上)
# init_on_free=1       : メモリ解放時にゼロ初期化を行う(セキュリティ向上)
# page_alloc.shuffle=1 : メモリアロケーションの乱数化により、予測不能性の向上
# ipv6.disable=1       : IPv6機能を無効化(環境に応じて必要な場合は解除)
GRUB_CMDLINE_LINUX_DEFAULT="quiet slab_nomerge init_on_alloc=1 init_on_free=1 page_alloc.shuffle=1 ipv6.disable=1"

設定内容の反映

sudo update-grub

Sambaの設定

Sambaのインストール

sudo dnf install samba -y

Sambaユーザの作成

sudo pdbedit -a '{ユーザ名}'

{ユーザ名}は好きなものに変更してください。

smb.confの設定

下記のように設定を変更する。

/etc/samba/smb.conf
[global]
    # Network settings
    bind interfaces only = yes
    hosts allow = 192.168.0.0/16
    
    # Charset
    unix charset = UTF-8
    
    # Security settings
    encrypt passwords = true
    smb encrypt = required
    restrict anonymous = 2
    min protocol = SMB3
    ntlm auth = no
    security = user
    invalid users = root daemon ftp network nobody ntp dnsmasq logd ubus syncthing
    map to guest = Never
    null passwords = no
    passdb backend = tdbsam
    smb ports = 445
    server signing = mandatory
    client signing = mandatory
    guest ok = no

    # Locking and connection settings
    strict locking = yes
    max connections = 2
    deadtime = 10
    enable core files = no
    
    # NetBIOS and spool settings
    disable netbios = yes
    disable spoolss = yes
    
    # Socket options
    socket options = IPTOS_LOWDELAY TCP_NODELAY
    
    # Printer settings
    load printers = No
    printcap name = /dev/null
    printing = bsd

[SSD]
    path = /mnt/ssd/
    directory mask = 0755
    create mask = 0644
    writable = yes

pathは自由に設定してください。今回はポータブルSSDを利用するため、マウントポイント/mnt/ssd/を設定しています。

Sambaサービスを有効化

sudo systemctl enable smb

USBポートのパススルー設定

左側のメニューのHardwareを選択し、左上のAddをクリックし、USB Deviceを選択します。
ポータブルSSDを挿入しているUSB Portを選択してAddを押下します。

インストール時に使用したCD/DVD DriveRemoveしておきます。

image.png

マウントポイントの作成

下記のコマンドを実行して、ssdディレクトリを作成します。

sudo mkdir /mnt/ssd/
sudo mount -t exfat /dev/sdb1 /mnt/ssd

Windowsでも外した際に中身を確認できるようにするため、exfatでフォーマットしています。

自動マウント

UUIDを知る必要があるため、下記のコマンドでマウントしたいUUIDを調べる

$ sudo blkid
/dev/sdb1: UUID="0E94-3399" BLOCK_SIZE="512" TYPE="exfat" PARTUUID="d3582af9-01"
/dev/sda2: UUID="e56c361d-1936-49b8-9220-fa9fe03b9121" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="e7d09a8d-36ff-4d57-acf2-bbf67c9c4c31"
/dev/sda1: UUID="E356-4AEF" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="195af5f4-d99e-454a-9ebb-2e1b4a21ae45"

再起動後に自動的にマウントするために、fstabを編集する。

/etc/fstab
UUID=0E94-3399 /mnt/ssd exfat defaults,uid={ユーザ名},gid={ユーザ名},context="system_u:object_r:samba_share_t:s0" umask=0000 0 0

{ユーザ名}は使用しているものを設定してください

SELinuxの設定

/mnt/ssdをSamba共有できるようにSELinuxのルールを追加

sudo semanage fcontext -a -t samba_share_t "/mnt/ssd(/.*)?"

Syncthingの設定

Syncthingをインストールする。

sudo dnf install syncthing -y

設定ファイルの変更

SyncthingのWEB GUIのアドレスを変更する。

~/.local/state/syncthing/config.xml
- <address>127.0.0.1:8384</address>
+ <address>{IPアドレス}</address>

{IPアドレス}は自由に設定してください

Syncthingの自動起動を設定する。

sudo systemctl enable syncthing@{ユーザ名}.service
sudo systemctl start syncthing@{ユーザ名}.service

{ユーザ名}は使用しているものを設定してください

Syncthingを設定

http://{IPアドレス}:8384/にアクセスし、初期設定を行う。

最後に

私はスマホではSyncthingを使ってファイル共有し、PCではSambaを使ってファイル共有しています。どちらも快適に使えているので、ぜひ試してみてください。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?