修正ubuntu 16.04.5系統上vsftpd服務無法啟動的問題
一直使用的伺服器使用的是ubuntu 16.04.5
,預設啟用了vsftpd
服務。但是最近在執行軟體更新之後,出現vsftpd
服務無法啟動的問題。
當時是按照ofollow,noindex" target="_blank">Centos/Ubuntu FTP伺服器的架設和配置 進行配置的。
具體的錯誤資訊如下:
root@xxxx:~# service vsftpd status ● vsftpd.service - vsftpd FTP server Loaded: loaded (/etc/systemd/system/vsftpd.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2018-11-03 20:36:08 CST; 1min 53s ago Process: 31620 ExecStart=/usr/sbin/vsftpd /etc/vsftpd.conf (code=exited, status=2) Process: 31617 ExecStartPre=/bin/mkdir -p /var/run/vsftpd/empty (code=exited, status=0/SUCCESS) Main PID: 31620 (code=exited, status=2) Nov 03 20:36:08 xxxx systemd[1]: Starting vsftpd FTP server... Nov 03 20:36:08 xxxx systemd[1]: Started vsftpd FTP server. Nov 03 20:36:08 xxxx systemd[1]: vsftpd.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Nov 03 20:36:08 xxxx systemd[1]: vsftpd.service: Unit entered failed state. Nov 03 20:36:08 xxxx systemd[1]: vsftpd.service: Failed with result 'exit-code'
root@xxxx:~# sudo systemctl status vsftpd.service ● vsftpd.service - vsftpd FTP server Loaded: loaded (/etc/systemd/system/vsftpd.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2018-11-03 20:47:51 CST; 1min 34s ago Process: 31820 ExecStart=/usr/sbin/vsftpd /etc/vsftpd.conf (code=exited, status=2) Process: 31817 ExecStartPre=/bin/mkdir -p /var/run/vsftpd/empty (code=exited, status=0/SUCCESS) Main PID: 31820 (code=exited, status=2) Nov 03 20:47:51 xxxx systemd[1]: Starting vsftpd FTP server... Nov 03 20:47:51 xxxx systemd[1]: Started vsftpd FTP server. Nov 03 20:47:51 xxxx systemd[1]: vsftpd.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Nov 03 20:47:51 xxxx systemd[1]: vsftpd.service: Unit entered failed state. Nov 03 20:47:51 xxxx systemd[1]: vsftpd.service: Failed with result 'exit-code'.
從錯誤資訊中,我們可以看到返回的錯誤資訊如下:
Process: 31820 ExecStart=/usr/sbin/vsftpd /etc/vsftpd.conf (code=exited, status=2)
錯誤程式碼為2
,查詢Linux
的系統錯誤程式碼,錯誤資訊為"errno2 :No such file or directory
"。
開啟/etc/vsftpd.conf
,可以看到,裡面的配置檔案中
# This option specifies the location of the RSA certificate to use for SSL # encrypted connections. rsa_cert_file=/etc/ssl/private/vsftpd.pem
我們發現已經找不到這個SSL
證書了。
解決方法如下:
1.首先移除已經安裝好的服務,並且刪除配置檔案
$ sudo apt-get remove --purge vsftpd $ sudo apt-get install vsftpd
然後按照Centos/Ubuntu FTP伺服器的架設和配置 重新配置一遍。安裝的時候,會自動搜尋系統已經安裝的有效證書,如果找不到,會自己生成一份證書。
2.也可以手工生成一份自簽名的證書, 推薦這個方法
$ sudo openssl req -x509 -nodes -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem -days 365 -newkey rsa:2048
參考連結
How to secure VSFTPD FTP Server using a self-signed SSL/TLS certificate in CentOS 7 – FTPS