Summary ¶
TrueNAS にはデータ保護の仕組みとして Cloud Sync Tasks というのがある。
これはバックエンドで Rclone
を利用している。
つまり、緊急時にファイル単体を手元の Windows などに Rclone インストールすれば閲覧できるのではないか? と思ったので試しておく
挙動としては Versioning + Object Lock を有効に設定して正しく設定すると IAM User でファイルを削除した場合、「削除した」という macker がオブジェクトに付与されて aws s3 ls
や IDrive e2 の WebGUI からは見えなくなる。が非表示になっているだけで Versioning 画面で確認できる。その画面で削除することができるが、これを制限するために Retention Mode Governance
に設定する。そうすると最新バージョンには削除操作に制限が付き一定期間がすぎるまで削除できないようになる。
これをしておくことで、オペレーションミスやランサムウェアで暗号化されてしまう被害を軽減できる。
ランサムウェアの場合手法としてすべてのファイルを暗号化したデータに置き換えられるか、一箇所のファイルを残してそれ以外は削除されてしまう攻撃になるため。今回の対策を実施することでファイルの完全削除は30日後、暗号化したバージョンで置き換えられた場合も14日以内なら救出できる。
Bucket の作成 ¶
ローカルの TrueNAS がランサムウェアに侵害された場合に備えて、 WORM(Write Once Read Many) を設定する。
これは S3 の仕組みでやるには Versioning
と Object Lock
の両方が必要
- リージョン: Singapore (地理的に近いので)
- Bucket Name: お好きに
- Files in bucket are: Private
- Default encryption: □ (On にすると Rclone での同期が失敗するので触らない)
- Versioning: ■
- Object Lock: ■

- Object Retention: ■
- Retention Mode
- Rules for older version
- After a specific duration since creation: 15

Governance mode で大丈夫なのか?

Modes of data retention in IDrive® e2
- Compliance mode: In this mode the object cannot be modified by any user or even IDrive® e2 personnel until the end of their retention period. The retention date of such an object also cannot be shortened.
- Governance mode: In this mode only the account owner or the root user can modify the retention settings.
― Object Lock for IDrive® e2 Cloud Storage
Access Key の作成 ¶
Important
Access key は残念ながら作成時しか Bucket を選択できません、そのため後から別の Bucket を選択する場合は Access Key を再作成して対象のシステムに登録してあるやつを更新する必要が出てきます。
また、ランサムウェア対策のもかねているため権限に Allow bucket deletion
が付与されていると余計な権限を付与してしまい被害が拡大するので最小限としましょう。
IDrive e2 の場合は Bucket を選択すると自動的に選択が解除され消える仕様のようなので問題ありません。確実に Bucket を選択しましょう。

緊急時の取り出し方法 ¶
セットアップの方で書いている、方法で実施していると下記のファイル/フォルダーが暗号化され
1
2
3
4
5
6
7
| ## Remote Encryption: □, Filename Encryption: □
test-sg-exsample-0001
├── DLSite
│ └── naa0yama
│ └── 2023-12-04 01.13.42 10.2.21.97 cf86975565c1.png
└── ISO_files
└── 2023-12-04 01.13.42 10.2.21.97 cf86975565c1.png
|
下記のようになる、またファイルも暗号化されているためランサムウェアで暗号化された状態をお楽しみ頂ける状態となっている。
1
2
3
4
5
6
| ## Remote Encryption: ■, Filename Encryption: ■
└── r8a07rjo2f1e4o1jjpmonmnjus
│ └── 2gd0nijnth3dfcs8tam446l3v0
│ └── ef3ihrcr7913gbggqv9k2eomt895si008rqqrstcq9t2kqs96qjlgclhn8m2vs8gkehc745ob3vn2
└── bvknpir1oln4qp9868ok9ge9to
└── ef3ihrcr7913gbggqv9k2eomt895si008rqqrstcq9t2kqs96qjlgclhn8m2vs8gkehc745ob3vn2
|
これでは緊急時にファイルとして取り出せないため、 Windows で手元に Rclone をセットアップしてファイルを取り出す方法を確認しておく。
Rclone downloads
から適当にダウンロードして解凍解凍先のフォルダーを PowerShell で開いて設定をしていく
設定 ¶
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
| PS D:\rclone-v1.65.0-windows-amd64> .\rclone.exe config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
Enter name for new remote.
name> e2
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, ArvanCloud, Ceph, ChinaMobile, Cloudflare, DigitalOcean, Dreamhost, GCS, HuaweiOBS, IBMCOS, IDrive, IONOS, LyveCloud, Leviia, Liara, Linode, Minio, Netease, Petabox, RackCorp, Rclone, Scaleway, SeaweedFS, StackPath, Storj, Synology, TencentCOS, Wasabi, Qiniu and others
\ (s3)
Storage> 5
Option provider.
Choose your S3 provider.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
12 / IDrive e2
\ (IDrive)
provider> 12
Option env_auth.
Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars).
Only applies if access_key_id and secret_access_key is blank.
Choose a number from below, or type in your own boolean value (true or false).
Press Enter for the default (false).
1 / Enter AWS credentials in the next step.
\ (false)
2 / Get AWS credentials from the environment (env vars or IAM).
\ (true)
env_auth> 1
Option access_key_id.
AWS Access Key ID.
Leave blank for anonymous access or runtime credentials.
Enter a value. Press Enter to leave empty.
access_key_id> AKIAIOSFODNN7EXAMPLE
Option secret_access_key.
AWS Secret Access Key (password).
Leave blank for anonymous access or runtime credentials.
Enter a value. Press Enter to leave empty.
secret_access_key> wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Option acl.
Canned ACL used when creating buckets and storing or copying objects.
This ACL is used for creating objects and if bucket_acl isn't set, for creating buckets too.
For more info visit https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
Note that this ACL is applied when server-side copying objects as S3
doesn't copy the ACL from the source but rather writes a fresh one.
If the acl is an empty string then no X-Amz-Acl: header is added and
the default (private) will be used.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
/ Owner gets FULL_CONTROL.
1 | No one else has access rights (default).
\ (private)
/ Owner gets FULL_CONTROL.
acl> 1
Edit advanced config?
y) Yes
n) No (default)
y/n> n
Configuration complete.
Options:
- type: s3
- provider: IDrive
- access_key_id: AKIAIOSFODNN7EXAMPLE
- secret_access_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- acl: private
- endpoint: hoge.sg.exsample.com
Keep this "e2" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
e2 s3
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q>
|
暗号化フォルダーなどは変更する
e2:test-sg-exsample-0001/DataVol1
<remote name>:<bucket name>/<folder name>
- Option password:
<TrueNAS の Encryption Password>
- Option password2:
<TrueNAS の Encryption Salt>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
| Current remotes:
Name Type
==== ====
e2 s3
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> n
Enter name for new remote.
name> crypt
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
14 / Encrypt/Decrypt a remote
\ (crypt)
Storage> 14
Option remote.
Remote to encrypt/decrypt.
Normally should contain a ':' and a path, e.g. "myremote:path/to/dir",
"myremote:bucket" or maybe "myremote:" (not recommended).
Enter a value.
remote> e2:test-sg-exsample-0001/DataVol1
Option filename_encryption.
How to encrypt the filenames.
Choose a number from below, or type in your own string value.
Press Enter for the default (standard).
/ Encrypt the filenames.
1 | See the docs for the details.
\ (standard)
filename_encryption> 1
Option directory_name_encryption.
Option to either encrypt directory names or leave them intact.
NB If filename_encryption is "off" then this option will do nothing.
Choose a number from below, or type in your own boolean value (true or false).
Press Enter for the default (true).
1 / Encrypt directory names.
\ (true)
directory_name_encryption> 1
Option password.
Password or pass phrase for encryption.
Choose an alternative below.
y) Yes, type in my own password
g) Generate random password
y/g> y
Enter the password:
password:
Confirm the password:
password:
Option password2.
Password or pass phrase for salt.
Optional but recommended.
Should be different to the previous password.
Choose an alternative below. Press Enter for the default (n).
y) Yes, type in my own password
g) Generate random password
n) No, leave this optional password blank (default)
y/g/n> y
Enter the password:
password:
Confirm the password:
password:
Edit advanced config?
y) Yes
n) No (default)
y/n> n
Configuration complete.
Options:
- type: crypt
- remote: e2:test-sg-exsample-0001/DataVol1
- password: *** ENCRYPTED ***
- password2: *** ENCRYPTED ***
Keep this "crypt" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
crypt crypt
e2 s3
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
PS D:\rclone-v1.65.0-windows-amd64>
|
WebGUI でアクセスする ¶
ここまで準備ができたら Rclone 内包の WebGUI を起動すると中身が見えるはずである
この状態でブラウザが立ち上がるはず
1
2
3
4
| PS D:\rclone-v1.65.0-windows-amd64> .\rclone.exe rcd --rc-web-gui
2023/12/16 21:19:24 NOTICE: Web GUI exists. Update skipped.
2023/12/16 21:19:24 NOTICE: Serving Web GUI
2023/12/16 21:19:24 NOTICE: Serving remote control on http://127.0.0.1:5572/
|
先程設定した「crypt」の方ではフォルダー名とファイルを確認でき、「e2」の方ではフォルダー名、ファイル名、ファイル自体が暗号化されているのが確認できる

あとかたつけ ¶
Rclone の設定ファイルは Windows の場合 %USERPROFILE%\AppData\Roaming\rclone
へ保存される。ためこのファイルを削除しておけば問題ない。または rclone.exe config
を実行した時の s) Set configuration password
を利用することで設定ファイルそのものを暗号化してしまう手もあるが今回はバックアップストレージに閲覧確認なので削除した。
また、人によっては %USERPROFILE%\.aws
も確認しておくと良いだろう