macOS FTP服务器架设

macOS FTP服务器架设文章目录vsftpdmacOS安装配置vsftpd安装vsftpd安装前查看下说明brewinstallvsftpd修改vsftpd配置文件:/usr/local/etc/vsftpd.conf匿名登录+具备读写权限测试:手动启动vsftpd初始配置的连接修改后conf文件后的连接添加macOS开机启动项vsftpdmacOS安装配置vsftpd安装vsftpd安装前查看下说明➜~brewinfovsftpdvsftpd:stable3.0.3(bottled)Secu

vsftpd

macOS安装配置vsftpd

安装vsftpd

安装前查看下说明
➜  ~ brew info vsftpd
vsftpd: stable 3.0.3 (bottled)
Secure FTP server for UNIX
https://security.appspot.com/vsftpd.html
Not installed
From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/vsftpd.rb
==> Caveats
To use chroot, vsftpd requires root privileges, so you will need to run
`sudo vsftpd`.
You should be certain that you trust any software you grant root privileges.

The vsftpd.conf file must be owned by root or vsftpd will refuse to start:
  sudo chown root /usr/local/etc/vsftpd.conf

To have launchd start vsftpd now and restart at startup:
  sudo brew services start vsftpd
Or, if you don't want/need a background service you can just run:
  sudo vsftpd
brew install vsftpd
brew install vsftpd

查看文件都安装到了哪里

➜  ~ brew list vsftpd
/usr/local/Cellar/vsftpd/3.0.3/.bottle/etc/vsftpd.conf
/usr/local/Cellar/vsftpd/3.0.3/homebrew.mxcl.vsftpd.plist
/usr/local/Cellar/vsftpd/3.0.3/sbin/vsftpd
/usr/local/Cellar/vsftpd/3.0.3/share/man/ (2 files)

修改vsftpd配置文件 : /usr/local/etc/vsftpd.conf

查看下初始默认配置grep -v "#" /usr/local/etc/vsftpd.conf

anonymous_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
listen=YES

创建ftp文件夹

➜  /var sudo mkdir /var/ftp
➜  /var stat /var/ftp
16777220 38247940 drwxr-xr-x 2 root wheel 0 64 "Jan  4 12:55:32 2021" "Jan  4 12:55:32 2021" "Jan  4 12:55:32 2021" "Jan  4 12:55:32 2021" 4

将ftp文件夹配置为匿名登录的默认文件夹

anon_root=/var/ftp

经过实际操纵,匿名用户无法对根目录完成读写,根目录下创建专用文件夹,并赋予写权限

sudo mkdir /var/ftp/data
sudo chmod a+w /var/ftp/data
匿名登录+具备读写权限

修改配置

最终匿名读写的配置

➜  ~ grep -v "#" /usr/local/etc/vsftpd.conf
anonymous_enable=YES

write_enable=YES
anon_root=/var/ftp
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
listen=YES

测试:手动启动vsftpd

初始配置的连接

按照发行说明开启服务失败

➜  ~ sudo brew services start vsftpd
Password:
Error: Unknown command: services
➜  ~

手动开启vsftpd

➜  ~ sudo /usr/local/Cellar/vsftpd/3.0.3/sbin/vsftpd
Password:
500 OOPS: config file not owned by correct user, or not a file

➜  ~ sudo /usr/local/Cellar/vsftpd/3.0.3/sbin/vsftpd  /usr/local/etc/vsftpd.conf
500 OOPS: config file not owned by correct user, or not a file
➜  ~ stat /usr/local/etc/vsftpd.conf
16777220 38246688 -rw-r--r-- 1 plato admin 0 4593 "Jan  4 12:36:26 2021" "Jan  4 12:35:20 2021" "Jan  4 12:35:20 2021" "Jan  4 12:35:20 2021" 4096 16 0 /usr/local/etc/vsftpd.conf

#修正文件权限
➜  ~ sudo chown root /usr/local/etc/vsftpd.conf
➜  ~ sudo /usr/local/Cellar/vsftpd/3.0.3/sbin/vsftpd  /usr/local/etc/vsftpd.conf

连接测试

➜  ~ ftp
ftp> open localhost
ftp: connect to address ::1: Connection refused
ftp: Trying 127.0.0.1 ...
Connected to localhost.
220 (vsFTPd 3.0.3)
Name (localhost:plato): ftp
331 Please specify the password.
Password:
230 Login successful.
ftp> dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
226 Directory send OK.
ftp> put 100.txt
200 PORT command successful. Consider using PASV.
550 Permission denied.
ftp>
修改后conf文件后的连接
➜  ~ sudo /usr/local/Cellar/vsftpd/3.0.3/sbin/vsftpd  /usr/local/etc/vsftpd.conf

通用匿名账户名ftpanonymous,密码无

➜  ~ ftp
ftp> open localhost
ftp: connect to address ::1: Connection refused
ftp: Trying 127.0.0.1 ...
Connected to localhost.
220 (vsFTPd 3.0.3)
Name (localhost:plato): ftp
331 Please specify the password.
Password:
230 Login successful.
ftp> cd data
250 Directory successfully changed.
ftp> put 100.txt
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
912 bytes sent in 0.00018 seconds (4.83 Mbytes/s)
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-------    1 98       0             912 Jan 04 05:05 100.txt
226 Directory send OK.
ftp> delete 100.txt
250 Delete operation successful.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
226 Directory send OK.
ftp>

添加macOS开机启动项

sudo cp -v /usr/local/Cellar/vsftpd/3.0.3/homebrew.mxcl.vsftpd.plist /System/Library/LaunchDaemons
sudo launchctl load /System/Library/LaunchDaemons/homebrew.mxcl.vsftpd.plist

今天的文章macOS FTP服务器架设分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/5560.html

(0)
编程小号编程小号

相关推荐

发表回复

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