忍者ブログ

◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?

LinuC(Linux技術者認定資格)&リナックスサーバ構築設定事例

   
カテゴリー「Linux_FTP」の記事一覧

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

【Linux】anonymous FTP設定

#=============================
# ディレクトリ権限の設定
#-----------------------------
chmod 777 /var/ftp/pub
ls -ld /var/ftp/pub
#=============================
# /etc/vsftpd/vsftpd.conf
#-----------------------------
vi /etc/vsftpd/vsftpd.conf
  # anonymous/IPv4有効、IPv6無効
  ★  anonymous_enable=YES
  ★  anon_upload_enable=YES
  ★  local_enable=NO
      write_enable=YES
      local_umask=022
      dirmessage_enable=YES
      xferlog_enable=YES
      connect_from_port_20=YES
      xferlog_std_format=YES
  ★  listen=YES
  ★  listen_ipv6=NO
      pam_service_name=vsftpd
      userlist_enable=YES
  # アスキーモード/ダウンロードの許可
  ★  ascii_download_enable=YES
  ★  ascii_upload_enable=YES
  ★  download_enable=YES
      dirlist_enable=YES
      hide_ids=YES
      force_dot_files=YES
  # マスク値の設定変更
  ★  file_open_mode=0777
  ★  local_umask=000
  # パッシブポート/ローカルタイム等
  ★  pasv_max_port=70010
  ★  pasv_min_port=70000
  ★  tcp_wrappers=NO
  ★  use_localtime=YES
  ★  virtual_use_local_privs=YES
  # anonymous追加設定
  ★  anon_upload_enable=YES
  ★  anon_other_write_enable=YES
  ★  anon_mkdir_write_enable=YES
  ★  anon_umask=000
  ★  no_anon_password=YES
#=============================
# vsftpdサービス起動
#-----------------------------
systemctl restart vsftpd
#=============================
# 匿名FTP接続テスト
#-----------------------------
ftp -A 192.168.222.3
  Connected to 192.168.222.3 (192.168.222.3).
  220 (vsFTPd 3.0.3)
  Name (192.168.222.3:root): anonymous
  230 Login successful.
  Remote system type is UNIX.
  Using binary mode to transfer files.
  ftp> ls
  200 PORT command successful. Consider using PASV.
  150 Here comes the directory listing.
  drwxrwxrwx    2 ftp      ftp          4096 Jan 07  2022 pub
  226 Directory send OK.
  ftp> pwd
  257 "/" is the current directory
  ftp> cd /pub
  250 Directory successfully changed.
  ftp> pwd
  257 "/pub" is the current directory
  ftp> put anon.txt
  local: anon.txt remote: anon.txt
  200 PORT command successful. Consider using PASV.
  150 Ok to send data.
  226 Transfer complete.
  5 bytes sent in 0.000107 secs (46.73 Kbytes/sec)
  ftp> exit
  221 Goodbye.

#=============================
# パッシブモードの項目の注意
#-----------------------------
# スイッチとFTP接続する場合は無効化
  pasv_address
  pasv_enable
  pasv_max_port
  pasv_min_port
  pasv_promiscuous
PR

【Linux】FTP設定

#=============================
# ■ FTPのインストール
#-----------------------------
dnf -y install vsftpd
#=============================
# ■ FTPの設定
#-----------------------------
vi /etc/vsftpd/vsftpd.conf
  ## chrootのローカルユーザ無効化
  chroot_local_user=NO
  ## chrootリスト有効化
  chroot_list_enable=YES
  ## chrootリストファイルの場所
  chroot_list_file=/etc/vsftpd/chroot_list
  ## userlist_fileの有効化(デフォルト値)
  userlist_enable=YES
  ## アクセスファイルの無効化
  tcp_wrappers=NO
  ## パッシブモード有効化
  pasv_enable=YES
  ## FTPサーバのIPアドレス設定
  pasv_address=192.168.222.50
  ## パッシブモードのポート設定
  pasv_min_port=30001
  pasv_max_port=30010
  ## ドットファイルも含めて一覧表示させる
  force_dot_files=YES
  ## ファイルのタイムスタンプ表示
  use_localtime=YES
  ## ユーザーの設定ファイル格納場所
  user_config_dir=/etc/vsftpd/user_conf
  ## 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
  allow_writeable_chroot=YES
#=============================
# ■ FTP接続用ユーザ作成
#-----------------------------
useradd testftp
#=============================
# ■ パスワード設定
#-----------------------------
passwd testftp
#=============================
# ■ FTP用のディレクトリchrootの設定
#-----------------------------
mkdir -p /var/www/FTP
chown testftp /var/www/FTP
chmod 755 /var/www/FTP
s -ld /var/www/FTP
#=============================
# ■ FTP接続用ユーザの登録
#-----------------------------
vi /etc/vsftpd/chroot_list
testftp
root
#=============================
# ■ chrootのディレクトリを設定する
#-----------------------------
mkdir /etc/vsftpd/user_conf
ls -l /etc/vsftpd/user_conf
#-----------------------------
vi /etc/vsftpd/user_conf/testftp
local_root=/var/www/FTP
#-----------------------------
vi /etc/vsftpd/user_conf/root
local_root=/var/www/FTP
#=============================
# ■ テスト用ファイル作成
#-----------------------------
cd /var/www/FTP
pwd
echo "FTP test" > FTP_test.txt
ls -l /var/www/FTP
#=============================
# ■ root接続の許可①
# /etc/vsftpd/ftpusersのrootをコメントアウト
#-----------------------------
vi /etc/vsftpd/ftpusers
  #root
#-----------------------------
cat /etc/vsftpd/ftpusers
#=============================
# ■ root接続の許可②
# /etc/vsftpd/user_listのrootをコメントアウト
#-----------------------------
vi /etc/vsftpd/user_list
  #root
#-----------------------------
cat /etc/vsftpd/user_list
#=============================
# ■ nftables/Firewallの無効化
#-----------------------------
#【firewalldのバックエンド確認】
#-----------------------------
cat /etc/firewalld/firewalld.conf | egrep -v "(^$|^#)" | grep "FirewallBackend"
#=============================
#【サービス状態確認】
#-----------------------------
systemctl status firewalld --no-pager
systemctl status nftables --no-pager
systemctl -t service list-unit-files | egrep "(iptables|nftables|firewalld)"
#=============================
#【ファイアウォール無効化】
#-----------------------------
systemctl disable firewalld
systemctl stop firewalld
#=============================
#【nftables無効化】
#-----------------------------
systemctl disable nftables
systemctl stop nftables
#=============================
#【サービス状態確認】
#-----------------------------
systemctl status firewalld --no-pager
systemctl status nftables --no-pager
systemctl -t service list-unit-files | egrep "(iptables|nftables|firewalld)"
#=============================
# ■ SELinux設定(設定反映に再起動が必要)
#-----------------------------
# 変更前のSELINUX
#-----------------------------
cat /etc/selinux/config | grep "SELINUX"
#=============================
#【GRUB2 メニューエントリーの確認】
#-----------------------------
cat /etc/default/grub | grep selinux=0
grubby --info=ALL | grep selinux=0
#=============================
#【SELinux設定確認】
#-----------------------------
sestatus | grep status
getenforce
#=============================
#【カーネルコマンドライン⇒SELinuxの無効化】
#-----------------------------
grubby --update-kernel ALL --args selinux=0
#=============================
#【再起動⇒SELinux設定反映】
#-----------------------------
reboot
#=============================
# ■ SELinux設定(再起動後の確認)
#-----------------------------
# 変更後のSELINUX
#-----------------------------
cat /etc/selinux/config | grep "SELINUX"
#=============================
#【GRUB2 メニューエントリーの確認】
#-----------------------------
cat /etc/default/grub | grep selinux=0
grubby --info=ALL | grep selinux=0
#=============================
#【SELinux設定確認】
#-----------------------------
sestatus | grep status
getenforce
#=============================
# ■ FTP サービス起動
#-----------------------------
systemctl status vsftpd
systemctl restart vsftpd
systemctl status vsftpd
#=============================
## ■ Windowsの端末からFTP接続を確認する
#-----------------------------
  ※Windowsのファイアウォール無効化しておく
>ftp 192.168.222.50
ユーザー ([FTPサーバーのIPアドレス]:(none)):testftp
331 Please specify the password.<パスワード>
230 Login successful.
ftp>pwd
ftp>ls
ftp>quit

更新日付

05 2025/06 07
S M T W T F S
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

RECOMMEND

プロフィール

HN:
Account
HP:
性別:
非公開
職業:
--- NODATA ---
趣味:
--- NODATA ---
自己紹介:
◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?

リンク

 | HOME | 
Copyright ©  -- LinuC(Linux技術者認定資格)&リナックスサーバ構築設定事例 --  All Rights Reserved
Design by CriCri / Photo by Melonenmann / powered by NINJA TOOLS / 忍者ブログ / [PR]