WindowsからLinuxにスクリプトでファイルを送りたかったので。
Linux側から取るならsmbとかnfsでできるんだろうけど、Windows側から送りたかったので、Linux側にftpサーバを入れた。
Linux側でのサーバ設定
#ftpサーバインストール
[root@GAIA /]# yum -y install vsftpd
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.tsukuba.wide.ad.jp
* epel: ftp.riken.jp
* extras: ftp.tsukuba.wide.ad.jp
* updates: ftp.tsukuba.wide.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ vsftpd.x86_64 0:3.0.2-21.el7 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
================================================================================
Package アーキテクチャー バージョン リポジトリー 容量
================================================================================
インストール中:
vsftpd x86_64 3.0.2-21.el7 base 169 k
トランザクションの要約
================================================================================
インストール 1 パッケージ
総ダウンロード容量: 169 k
インストール容量: 348 k
Downloading packages:
vsftpd-3.0.2-21.el7.x86_64.rpm | 169 kB 00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : vsftpd-3.0.2-21.el7.x86_64 1/1
検証中 : vsftpd-3.0.2-21.el7.x86_64 1/1
インストール:
vsftpd.x86_64 0:3.0.2-21.el7
完了しました!
[root@GAIA /]#
#サービス初期設定
[root@GAIA /]#
[root@GAIA /]# systemctl start vsftpd.service
[root@GAIA /]#
[root@GAIA /]# systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
Active: active (running) since 日 2017-05-21 05:58:56 JST; 11s ago
Process: 62698 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 62700 (vsftpd)
CGroup: /system.slice/vsftpd.service
mq62700 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
5月 21 05:58:56 GAIA systemd[1]: Starting Vsftpd ftp daemon...
5月 21 05:58:56 GAIA systemd[1]: Started Vsftpd ftp daemon.
[root@GAIA /]#
[root@GAIA /]# systemctl enable vsftpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
#rootユーザを許可
[root@GAIA /]# sed -i 's/root/#root/g' /etc/vsftpd/user_list /etc/vsftpd/ftpusers
#ftpサービスのファイアウォールを許可
[root@GAIA /]# firewall-cmd --add-service=ftp --zone=public
success
[root@GAIA /]# firewall-cmd --list-services --zone=public
dhcpv6-client ftp http ssh
[root@GAIA /]#
Windows側のクライアントからファイルを送ってみる。
rootユーザで1.txtまたは1,2,3.txtの複数送信してみるよ。
Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\Users\雄太>ftp 192.168.0.43 192.168.0.43 に接続しました。 220 (vsFTPd 3.0.2) 200 Always in UTF8 mode. ユーザー (192.168.0.43:(none)): root 331 Please specify the password. パスワード: 230 Login successful. ftp> ftp> pwd 257 "/root" ftp> cd /tmp 250 Directory successfully changed. ftp> dir 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. drwx------ 3 0 0 16 Apr 29 00:00 systemd-private-1e08c3ea59d34517875b6aaeeff09765-colord.service-QcJK5v drwx------ 3 0 0 16 Apr 28 23:58 systemd-private-1e08c3ea59d34517875b6aaeeff09765-cups.service-0M1led drwx------ 3 0 0 16 May 20 17:13 systemd-private-1e08c3ea59d34517875b6aaeeff09765-httpd.service-bgJHz4 drwx------ 3 0 0 16 Apr 28 23:58 systemd-private-1e08c3ea59d34517875b6aaeeff09765-rtkit-daemon.service-dhdbIQ 226 Directory send OK. ftp: 518 バイトが受信されました 0.03秒 16.71KB/秒。 ftp> pwd 257 "/tmp" ftp> lcd c:\tmp ローカル ディレクトリは現在 C:\tmp です。 ftp> put 1.txt 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 Transfer complete. ftp> ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. 1.txt systemd-private-1e08c3ea59d34517875b6aaeeff09765-colord.service-QcJK5v systemd-private-1e08c3ea59d34517875b6aaeeff09765-cups.service-0M1led systemd-private-1e08c3ea59d34517875b6aaeeff09765-httpd.service-bgJHz4 systemd-private-1e08c3ea59d34517875b6aaeeff09765-rtkit-daemon.service-dhdbIQ 226 Directory send OK. ftp: 301 バイトが受信されました 0.08秒 3.86KB/秒。 ftp> ftp> mput 1.txt 2.txt 3.txt mput 1.txt? y 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 Transfer complete. mput 2.txt? y 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 Transfer complete. mput 3.txt? y 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 Transfer complete. ftp> ftp> ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. 1.txt 2.txt 3.txt systemd-private-1e08c3ea59d34517875b6aaeeff09765-colord.service-QcJK5v systemd-private-1e08c3ea59d34517875b6aaeeff09765-cups.service-0M1led systemd-private-1e08c3ea59d34517875b6aaeeff09765-httpd.service-bgJHz4 systemd-private-1e08c3ea59d34517875b6aaeeff09765-rtkit-daemon.service-dhdbIQ 226 Directory send OK. ftp: 315 バイトが受信されました 0.03秒 10.16KB/秒。 ftp>
