个人技术空间

cmd命令行设置windows的FTP服务

#首先安装IIS的FTP服务
dism /online /enable-feature /featurename:IIS-FTPServer /all
dism /online /enable-feature /featurename:IIS-FTPSvc /all

#然后进入appcmd的目录
cd /d c:\Windows\System32\inetsrv
#新增一个alienftp的站点,端口为21000,路径指向c:\alienftproot
appcmd.exe add site /name:alienftp /bindings:ftp://*:21000 /physicalpath:"c:\alienftproot"

#默认windows的ftp为被动模式,如果需要防火墙控制端口的话,需要指定被动模式下使用的端口。
这里指定端口范围为21001-21100
(这是一个全局的设置,如果IIS上有多个FTP服务的话会统一生效)
appcmd set config /section:system.ftpServer/firewallSupport /lowDataChannelPort:21001 /highDataChannelPort:21100

#在FTP授权规则中添加一个用户,设置读写权限
appcmd.exe set config "alienftp" -section:system.ftpServer/security/authorization /+"[accessType='Allow',users='alien',permissions='Read, Write']" /commit:apphost

#在FTP身份认证中启用基本身份验证
appcmd set config -section:system.applicationHost/sites /[name='alienftp'].ftpServer.security.authentication.basicAuthentication.enabled:true  

#这里是SSL相关,是否允许SSL的连接
appcmd set config -section:system.applicationHost/sites /[name='alienftp'].ftpServer.security.ssl.controlChannelPolicy:"SslAllow"  
appcmd set config -section:system.applicationHost/sites /[name='alienftp'].ftpServer.security.ssl.dataChannelPolicy:"SslAllow"  

版权声明:署名-非商业性使用-禁止演绎 3.0 未本地化版本 (CC BY-NC-ND 3.0)