LinuxからのSMB接続・mountと認証1 / 4
smbclientとmount.cifs
smbclientは対話的な転送や共有一覧、印刷等に使うuser spaceのclientである。mount.cifsはkernelのCIFS/SMB file systemとしてlocal directoryへ接続する。smbclient成功でもmountに必要なkernel module、helper、mount権限、client側のoptionがそろうとは限らない。
smbclient -L files.example.test -U alice
smbclient //files.example.test/project -U alice -c 'ls'
mount -t cifs //files.example.test/project /mnt/project -o credentials=/root/project.cred,vers=3.1.1,seal
これはSMB3.1.1と暗号化へ対応するserver/clientの例である。project.credにはusername、password、必要なdomainを各行へ保存する。秘密fileはroot所有0600等で保護し、共用の/etc/fstabやcommand引数へpasswordを直接書かない。
username=alice
password=LAB_ONLY_REPLACE_THIS
domain=EXAMPLE
//files.example.test/project /mnt/project cifs credentials=/root/project.cred,vers=3.1.1,seal,_netdev 0 0
credentialsの値はその接続の認証identityである。uid/gidやfile_mode/dir_modeはserverが属性を返さない場合等のlocal表示・権限へ関わるoptionで、serverへ別userとして認証する設定ではない。nopermはclient側の権限検査を省くが、server ACLの拒否を消さない。