当我尝试连接本地 FTP 服务器时收到以下错误消息:
$ 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
我已经在我的 High Sierra MacOS 上安装了 pure-ftpd,如下所示:
$ brew install pure-ftpd
在此之后,我开始了:
$ brew services list | grep ftp
proftpd stopped
pure-ftpd started alexandre1202 /Users/alexandre1202/Library/LaunchAgents/homebrew.mxcl.pure-ftpd.plist
vsftpd stopped
我也尝试过 vsftpd 和 profptd,但问题是一样的。
从上面我们可以看到,服务已经启动,但是我检查了本地连接,发现 21 端口没有 ESTABLISHED 或者 LISTEN
# netstat -f inet -tan | grep 21
此外,我还通过系统上的任何 ftp 服务器进行了检查
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#
如果我尝试使用以下命令进行连接,我们可以看到没有 LISTEN 服务:
# telnet localhost 21
Trying ::1...
Connection failed: Connection refused
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
我非常感激任何帮助我弄清楚为什么我不能本地使用 FTP 服务器的帮助。
答案1
执行以下步骤后问题已解决:
1)我已停止服务
$ brew services stop pure-ftpd
2)我已移除服务
$ brew remove pure-ftpd
3)我已经更新了 brew
$ brew upgrade
4)我已经清理过了
$ brew cleanup
5)我已重新安装
$ brew install pure-ftpd
6)我使用root权限创建了/etc/pam.d/pure-ftpd以下几行:
# 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)设置pam配置
sudo /usr/local/sbin/pure-ftpd -lpam -B
8)我已重启服务
$ brew services restart pure-ftpd
9)最后连接成功!
$ 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>