修正ubuntu 16.04.5系统上vsftpd服务无法启动的问题

一直使用的服务器使用的是ubuntu 16.04.5,默认启用了vsftpd服务。但是最近在执行软件更新之后,出现vsftpd服务无法启动的问题。

当时是按照 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

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注