但是要將檔案送到主機上,FTP倒是一種經常用的途徑之一
因此使用FTP server當做檔案接收的服務,有需要用時開啟用完則關
因為指令太多了在此紀錄一下
首先先切換到root權限(這樣指令可以少打sudo :p)
安裝 vsftpd:
yum -y install vsftpd
touch /etc/vsftpd/chroot_list
chkconfig vsftpd on
設定防火牆開通Port 21 :
防火牆iptables位置在 /etc/sysconfig/iptables可透過指令直接新增
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
service iptables save
編輯 "/etc/vsftpd/vsftpd.conf"
vi /etc/vsftpd/vsftpd.conf
設定
anonymous_enable=YES
改成
anonymous_enable=NO
限制用戶只能在自己的用戶目錄"/home/[Account]"則在裡面加入:
限制用戶只能在家目錄 (/etc/vsftpd/chroot_list 的用戶可不受限制)
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
將 ftp 的檔案列表能看到跟 Server 上同樣的時間,在檔案加入:
# 使用本地時區
use_localtime=YES
重新啟動 vsftpd:
service vsftpd restart
以上設定就初步架好FTP Server了,但如果使用root登入FTP 出現會回傳530 Permission denied.
原因是安全性的關係vsftp預設會將系統一些特殊的帳號設定為封鎖
訊息大概如下
ftp 192.168.0.118
Connected to 192.168.1.100 (192.168.1.100).
220 Welcome to [computer name] FTP Server.
Name (192.168.1.100:root): root
530 Permission denied.
Login failed.
ftp>如果要使用root登入FTP,要修改以下檔案
vi /etc/vsftpd/ftpusers
找到root 前面加上#號註解(清單內的帳號都是一些可能會被拿來亂用的)
vi /etc/vsftpd/ftpusers
# Users that are not allowed to login via ftpbin
#root
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
之後再移除user_list裡面的帳號
vi /etc/vsftpd/user_list
找到root前面加上#號註解
# vsftpd userlist# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.bin
#root
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody/etc/init.d/vsftpd restart或service vsftpd restart