Install SFTP in Windows
通过OpenSSH来创建SFTP Server:
安装
- 下载OpenSSH 安装包,https://github.com/PowerShell/Win32-OpenSSH/releases,文件名为OpenSSH-Win64.zip
- 将下载的文件OpenSSH-Win64.zip 进行解压,后把文件copy到c:\Program Files目录下
- 使用以administator账号打开cmd窗口
- 进入OpenSSH文件夹
命令: cd C:\Program Files\OpenSSH

5.安装SSH服务
命令 powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1

6.在防火墙开启端口22端口号
netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22

7. 启动ssh服务
net start sshd

8. 测试
Sftp administrator@localhost 启动SFTP来连接到server,account@server,然后输入密码,成功
配置:
- 在Computer Management里创建user account, SFTPA and SFTPB

- 到C:\ProgramData\ssh目录下找到文件sshd_config,打开这个文件,(注意这个目录是隐藏的,必须手动输入)。
- 在文档底部加入下面的语句
#=============================================
#Add Below
ForceCommand internal-sftp
Match User SFTPA
ChrootDirectory D:\BL\Repadmin
# Disable tunneling, authentication agent, TCP and X11 forwarding.
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
PermitTTY no
Match User SFTPB
ChrootDirectory D:\BL\SFTP
# Disable tunneling, authentication agent, TCP and X11 forwarding.
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
PermitTTY no
#===============================================
说明:
Match User SFTPA #检查登录的账号
ChrootDirectory D:\BL\Repadmin #自动转入到这个目录

4. 重启Services
net stop sshd
net start sshd
5. 使用Filezilla登录上面的账号:
设定账号:

登录完后就可以download/upload File了。

本文详细介绍如何在Windows系统中使用OpenSSH建立SFTP服务器,包括下载安装包、配置防火墙、设置用户权限及测试连接等步骤。适用于需要在Windows环境中提供安全文件传输服务的场景。
824

被折叠的 条评论
为什么被折叠?



