ArchLinux 2018.10.01: FTPクライアントのcurlftpfsをインストールする


Table of Contents

1 curlftpfsのインストール

curlftpfsパッケージをインストールします。

$ sudo pacman -Sy –noconfirm curlftpfs

2 curlftpfsでマウント

curlftpfsコマンドでmntディレクトリへマウントします。

$ FTP_SERVER=ftp-server.hiroom2.com$ FTP_USERNAME=foobar$ FTP_PASSWORD=foobar$ mkdir mnt$ curlftpfs -o user=${FTP_USERNAME} “${FTP_SERVER}” mntEnter host password for user ‘${FTP_USERNME}’:

user=<username>:<password>でパスワードを指定することもできます。

$ curlftpfs -o user=${FTP_USERNAME}:${FTP_PASSWORD} “${FTP_SERVER}” mnt

user=<username>:で~/.netrcに記載されたパスワードが使用されます。

$ cat <<EOF > ~/.netrcmachine ${FTP_SERVER}login ${FTP_USERNAME}password ${FTP_PASSWORD}EOF$ chmod 600 ~/.netrc$ curlftpfs -o user=${FTP_USERNAME}: “${FTP_SERVER}” mnt

ユーザを指定しない場合は匿名ユーザとしてマウントします。

$ curlftpfs “${FTP_SERVER}” mnt

allow_otherを指定すると他ユーザからのアクセスを許可します。 allow_rootを指定するとrootユーザからのアクセスを許可します。 allow_otherとallow_rootを指定しない場合はマウントしたユーザのみがアクセスできます。

$ curlftpfs -o user=${FTP_USERNAME},allow_other “${FTP_SERVER}” mnt

3 起動時にマウント

他のファイルシステムと同様に/etc/fstabに追記します。ネットワーク初期化前にマウントするのを防ぐために、_netdevをオプションを指定する必要があります。 x-systemd.automountにマウントさせるために、x-systemd.automountをオプションに指定する必要があります。

$ OPT=_netdev,x-systemd.automount,allow_other$ cat <<EOF | sudo tee -a /etc/fstabcurlftpfs#${FTP_USERNAME}:${FTP_PASSWORD}@${FTP_SERVER} /mnt fuse ${OPT} 0 0EOF

パスワードを記載しないようにするには/root/.netrcを作成します。

$ cat <<EOF | sudo tee /root/.netrcmachine ${FTP_SERVER}login ${FTP_USERNAME}password ${FTP_PASSWORD}EOF$ sudo chmod 600 /root/.netrc$ echo “curlftpfs#${FTP_USERNAME}:@${FTP_SERVER} /mnt fuse ${OPT} 0 0” | sudo tee -a /etc/fstab

Android | Linux | SDL - Narrow Escape