4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

さくらVPSにFTP(vsftpd)を導入

Last updated at Posted at 2015-02-22

vsftpdをインストール

$ yum install vsftpd

vsftpdを起動

$ sudo /etc/rc.d/init.d/vsftpd start

自動起動を有効化

$sudo chkconfig vsftpd on

vsftpd.confの設定

vsftpd設定ファイルのバックアップ
バックアップファイルを置くディレクトリは任意に。

$ mkdir vsftpd_conf_bk
$ sudo cp /etc/vsftpd/vsftpd.conf vsftpd_conf_bk

絶対パスでコマンドを書くのが面倒なので、該当ディレクトリに移動

$ cd /etc/vsftpd/ 

vsftpd設定ファイルを開く

$ sudo vim vsftpd.conf

以下vsftpd.confの設定

# 匿名アクセスの禁止
anonymous_enable=NO

# 設定したlocal_rootより上層ディレクトリへの移動を禁止
chroot_local_user=YES

# 設定したlocal_rootより上層ディレクトリへの移動を許可するユーザを設定
# 後述の/etc/vsftpd/chroot_listに移動を許可するユーザを記載
chroot_list_enable=YES

# アスキーモードを有効にする
ascii_upload_enable=YES
ascii_download_enable=YES

# -------以降、設定ファイル下部に追記
# /etc/vsftpd/user_listのユーザのみを許可する。
userlist_deny=NO

# パッシブモードを有効化を明示する
pasv_enable=YES

# xxxをftp接続した際のルートディレクトリとして設定する
local_root=/var/www/html/xxx

アクセスディレクトリの制限

/etc/vsftpd/chroot_list(デフォルトだと無いため自分で作成)
Screen Shot 2015-02-22 at 17.41.13.png

/etc/vsftpd/user_list
Screen Shot 2015-02-22 at 17.40.44.png

vsftpd.confの中で、

chroot_local_user=YES
chroot_list_enable=YES

とすることで、chroot_listに記載されたユーザーのみが、全ディレクトリに移動できる。

chroot_local_user=NO だと、/etc/vsftpd/chroot_listに未記載のユーザは、ログイン後に
該当ディレクトリ以外にもアクセスできてしまうため、どちらもYESが良いと思われる。

chrootについて詳しく知りたい方は、FTPサーバ(vsftpd)の構築(RedHat系編)

vsftpdの設定を反映

$ sudo /etc/rc.d/init.d/vsftpd restart
4
6
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
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?