Linux編譯安裝vsftpd伺服器(本機使用者驗證方式)_FTP伺服器

來源:互聯網
上載者:User

Linux vsftpd編譯安裝和配置允許本機使用者登入FTP

1、下載vsftpd源碼

wget https://security.appspot.com/downloads/vsftpd-2.3.4.tar.gz

2、編譯vsftpd源碼
64位的系統編譯之前先要執行cp /lib64/libcap.so.1 /lib/libcap.so.1命令:

複製代碼 代碼如下:

tar xzvf vsftpd-2.3.4.tar.gz
cd vsftpd-2.3.4
make
make install

3、配置vsftpd

複製代碼 代碼如下:

cp vsftpd.conf /etc
cp RedHat/vsftpd.pam /etc/pam.d/ftp
sed i 's/anonymous_enable/#anonymous_enable=YES/g' /etc/vsftpd.conf
sed i 's/#local_enable=YES/local_enable=YES/g' /etc/vsftpd.conf
sed i 's/#write_enable=YES/write_enable=YES/g' /etc/vsftpd.conf
sed i 's/#local_umask=022/local_umask=022/g' /etc/vsftpd.conf
sed i 's/#chroot_local_user=YES/chroot_local_user=YES/g' /etc/vsftpd.conf

4、啟動vsftpd並設定開機啟動

/usr/local/sbin/vsftpd &
sed -i '$a\/usr/local/sbin/vsftpd &' /etc/rc.d/rc.local

5、添加FTP使用者(使用者名稱:ftpuser ftp根目錄/home/wwwroot/ftpuser)

useradd -d /home/wwwroot/ftpuser -g ftp -s /sbin/nologin ftpuser

本機使用者驗證方式

(1)下載檔案

wget http://jaist.dl.sourceforge.net/project/buluoos/0.1/src/vsftpd-2.2.2.tar.gz
tar zxvf vsftpd-2.2.2.tar.gz
cd vsftpd-2.2.2

(2)編輯程式碼。用tcp_wrappers驗證方式,取消PAM驗證。

sed -i 's/undef VSF_BUILD_TCPWRAPPERS/define VSF_BUILD_TCPWRAPPERS/g' builddefs.h
sed -i 's/define VSF_BUILD_PAM/undef VSF_BUILD_PAM/g' builddefs.h

(3)安裝
make -j 8

(4)添加系統使用者“nobody”(此使用者可能已經存在)

useradd nobody

(5)建立目錄“/usr/share/empty”(此目錄可能已經存在)

mkdir /usr/share/empty/

(6)安裝vsftpd設定檔,可執行程式。

install -m 644 vsftpd.conf /etc/vsftpd.conf
install -m 755 vsftpd /usr/local/sbin/vsftpd
install -m 644 vsftpd.8 /usr/share/man/man8
install -m 644 vsftpd.conf.5 /usr/share/man/man5

(7)編輯設定檔

cat >>/etc/vsftpd.conf<<EOF
anonymous_enable=NO
local_enable=YES
write_enable=YES
tcp_wrappers=YES
EOF

(8)啟動vsftpd

/usr/local/sbin/vsftpd /etc/vsftpd.conf &

* 安裝後使用系統使用者登入,最好是使用運行WEB伺服器的使用者,這樣可以避免上傳之後再修改屬主屬組和許可權。
* 安裝檔案下載地址不在本地,如果失效,可以自行搜尋個下載地址,其他安裝步驟不影響。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.