pure-ftpd Connection refused localhost on high sierra
When I try connect my local FTP server I have received the following error message:
$ ftp localhost
ftp: connect to address ::1: Connection refused
ftp: Trying 127.0.0.1 ...
ftp: connect to address 127.0.0.1: Connection refused
ftp: no response from host
I have installed pure-ftpd on my High Sierra MacOS just like this:
$ brew install pure-ftpd
And after this I have started it:
$ brew services list | grep ftp
proftpd stopped
pure-ftpd started alexandre1202 /Users/alexandre1202/Library/LaunchAgents/homebrew.mxcl.pure-ftpd.plist
vsftpd stopped
I also have tried with vsftpd and profptd but the issue is the same.
As we can see above the service is started but when I also have checked local connections and 21 port is not ESTABLISHED or LISTEN
# netstat -f inet -tan | grep 21
In addition I have checked by any ftp server on system
alemacbookpro:~ root# ps aux | grep ftp
root 60696 0.0 0.0 4279600 0 s002 R 6:22PM 0:00.00 grep ftp
alemacbookpro:~ root#
And if I try connect using the following, we can see that there is no LISTEN service:
# telnet localhost 21
Trying ::1...
Connection failed: Connection refused
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
I apreciate any help to figure out why I can not use FTP server locally.
Solution 1:
Problem has fixed after the following steps:
1) I have stopped the service
$ brew services stop pure-ftpd
2) I have remove to service
$ brew remove pure-ftpd
3) I have updated brew
$ brew upgrade
4) I have cleaned it
$ brew cleanup
5) I have reinstalled it
$ brew install pure-ftpd
6) I have created the /etc/pam.d/pure-ftpd following lines using root privilege:
# pure-ftpd: auth account password session
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
7) Set pam configuration
sudo /usr/local/sbin/pure-ftpd -lpam -B
8) I have restart the service
$ brew services restart pure-ftpd
9) And finally the connection has successfully!
$ ftp localhost
Trying ::1...
Connected to localhost.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 20:42. Server port: 21.
220 You will be disconnected after 15 minutes of inactivity.
Name (localhost:alexandre1202):
331 User alexandre1202 OK. Password required
Password:
230 OK. Current directory is /Users/alexandre1202
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>