システム環境:
アリババクラウドECSホスト
| 12 | cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) |
|---|
1、 yumインストールを使用したインストール
| 1 | yum -y install vsftpd ftp |
|---|
2、 サービスカタログ
| 1 2 3 4 5 6 7 8 91011 | ツリー/ etc / vsftpd // etc / vsftpd /├──ftpusers├──user_list├──vconf#新しいディレクトリ│└──chenfei├──vsftpd.conf├──vsftpd.conf.bak#最初にバックアップを作成する├──vsftpd_conf_migrate.sh├──vusers#ユーザーファイル└──vusers.db |
|---|
3、 システムサービスにftpを追加し、起動します
| 1 | systemctl enable vsftpd |
|---|
4、 構成ファイルを変更する
| 1 2 3 4 5 6 7 8 91011121314151617181920212223242526272829303132 | anonymous_enable=NOlocal_enable=YESwrite_enable=YESlocal_umask=022anon_mkdir_write_enable=YESdirmessage_enable=YESxferlog_enable=YESconnect_from_port_20=YESchown_uploads=YESxferlog_std_format=YESasync_abor_enable=YESascii_upload_enable=YESascii_download_enable=YESftpd_banner=Welcome to blah FTP service.chroot_local_user=YESlisten=NOpam_service_name=vsftpduserlist_enable=YEStcp_wrappers=YESuse_localtime=YESlisten_port=21idle_session_timeout=300guest_enable=YESguest_username=vsftpduser_config_dir=/etc/vsftpd/vconfdata_connection_timeout=1virtual_use_local_privs=YESpasv_min_port=40000pasv_max_port=40010accept_timeout=5connect_timeout=1allow_writeable_chroot=YES |
|---|
5、 ユーザーファイルを作成する
| 1234 | cat / etc / vsftpd / vusersユーザー名パスワード |
|---|
ユーザー名とパスワードは別の行にある必要があり、順序は変更できません
6、 ユーザーデータファイルを生成する
| 1 | db_load -T -t hash -f /etc/vsftpd/vusers /etc/vsftpd/vusers.db |
|---|
7、 /etc/pam.d/vsftpdファイルを変更します
| 1 2 3 4 5 6 7 8 91011 | cat /etc/pam.d/vsftpd#%PAM-1.0session optional pam_keyinit.so force revoke#auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed#auth required pam_shells.so#auth include password-auth#account include password-authsession required pam_loginuid.sosession include password-authauth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vusers account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vusers |
|---|
元の認証アイテムとアカウントアイテムはコメントアウトされていることに注意してください
8、 システムユーザーvsftpdを作成します。ユーザーのホームディレクトリは/ home / vsftpdです。
| 1 | useradd vsftpd -d /home/vsftpd -s /bin/false |
|---|
sshがシステムにログインできないように、ユーザーログイン端末は/ bin / falseに設定されています
9、 仮想ユーザープロファイルを作成する
| 1 2 3 4 5 6 7 8 91011 | mkdir / etc / vsftpd / vconfcd / etc / vsftpd / vconfcat testlocal_root = / home / vsftpd / testwrite_enable = YESanon_world_読み取り可能のみ= NOanon_upload_enable = YESanon_mkdir_write_enable = YESanon_other_write_enable = YESanon_other_write_enable = YESanon_ |
|---|
10、 ファイアウォール設定
| 12 | - 入力-sネイティブIP / 32 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT-A INPUT-sネイティブIP / 32 -p tcp -m state --state NEW- m tcp --dport 40000:40010 -j ACCEPT |
|---|
11、 vsftpdサービスを再起動します
| 1 | systemctl restart vsftpd |
|---|
遭遇したピット:
アクセステストエラー:
1、500 OOPS: unrecognised variable in config file: xxxx
この種の構成ファイルは一般的に間違っています。ここでの私のエラーの理由は、仮想ユーザーの個人構成ファイルに誤りがあるためです。
2、200 Switching to ASCII mode 227 Entering Passive Mode
解決:
[ネットワークと共有センター]を開き、[インターネットオプション]-> [詳細]ページを見つけて、[パッシブFTPを使用する(ファイアウォールとDSLモデムの互換性のため)]をキャンセルします。
3、 匿名ユーザーアクセスが有効になっている場合、ディレクトリを作成および変更することはできません
解決:
| 12345 | 構成ファイルを変更します。anonymous_enable= YES#匿名ユーザーのログインを許可anon_upload_enable = YES#匿名ユーザーのアップロードを許可anon_other_write_enable = YESサービスを再起動します |
|---|
| 1 2 3 4 5 6 7 8 910111213 | lsリモートマシンの現在のディレクトリを一覧表示しますcdリモートマシンの作業ディレクトリlcdを変更しますローカルマシンの作業ディレクトリasciiを変更しますファイル転送モードをASCIIモードに設定しますbinaryファイル転送モードをバイナリモードに設定しますclose現在のftpセッションハッシュを終了しますデータが転送されるたびにバッファ内のデータの後、#番号が表示されます。get(mget)指定したファイルをリモートマシンからローカルマシンに転送しますput(mput)指定したファイルをローカルマシンからリモートマシンに転送しますopenリモートftpサイトに接続しますリモートマシンとの接続を切断し、 ftpを終了しますか?ローカルヘルプ情報を表示します!シェルに移動 |
|---|
ftpの使用中に発生した問題
1、 ftp:500 Illegal PORT command. ftp: bind: Address already in use
解決:
iptablesはそれをサポートしていないため、2つのモジュールをロードする必要があります。
| 12 | modprobe ip_nat_ftp modprobe ip_conntrack_ftp |
|---|
クライアントがコマンドラインまたはソフトウェアを使用して接続する場合、ftpサーバーの構成ファイルは、次の数行の構成があることを確認する必要があります。
| 1234 | pasv_enable = YESpasv_min_port = 40000 pasv_max_port = 40010pasv_promiscuous = YES#これが設定されていない場合、425セキュリティ:IP接続が不良です。これと同様のエラーが表示されます |
|---|
Recommended Posts