Cou氏の徒然日記

ほのぼの日記ブログです。

RHEL: FTPサーバー (vsftpd) 構築

続いて、Linuxマシンにファイルを転送するために、FTPサーバー構築

まずはパッケージのインストールです。

[root@coutest]# yum install vsftpd

 

ただ、前回のSSHのときもそうですが、このままだとファイアーウォールで通信が弾かれてしまうため、

[root@coutest]# ftp xxx.xxx.xxx.xxx
ftp: connect: No route to host

FTPサーバーに対して「No route to host」エラーとなってしまいます。

そのため、ファイアーウォールの通過設定をする必要があります。

 

ファイアーウォールの設定内容を確認すると…

[root@coutest]# firewall-cmd --list -all
public (default, active)
   interfaces: XXXX
   sources
   services: dhcpv6-client ssh
   ports:
   masquerade: no
   forward-ports:
   icmp-blocks:
   rich rules

前回、SSHを例外登録したので、SSHは通過できます。

これに、FTPも追加すればいいですね。

[root@coutest]# firewall-cmd --add-service=ftp --permanent
success

--permanentオプションで設定の恒久化しておかないと、再起動で戻ってしまうので、忘れないように注意ですね。(一回指定を忘れて、再起動したらつながらなくなってしまったことがありますので(苦笑))

 

設定を反映させるために、デーモンを再起動。

[root@coutest]# firewall-cmd --reload
success

 

試しに繋いでみると、

[root@coutest]# ftp xxx.xxx.xxx.xxx
Connected to xxx.xxx.xxx.xxx
220 (vsFTPd 1.2.1)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (xxx.xxx.xxx.xxx:root): 
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

 

無事に入れました。

このあたり、ハマると結構やっかいなので、一連の手順として押さえておいたほうがよいです。