You can use the official OpenSSH bundle for Windows to simply arrange a safe file switch between the consumer and Windows server utilizing the SFTP (Secure FTP) protocol. In this text, we are going to present the way to use the Win32-OpenSSH to run an SFTP server on Windows 10 or Windows Server 2016 / 2012R2.
What is SFTP?
SFTP (Secure File Transfer Protocol, Secure FTP or SSH FTP) is the extension of SSH protocol, being a normal on the earth of UNIX/Linux techniques. From the consumer viewpoint, it’s much like FTP, however actually, it’s a utterly completely different protocol, having nothing in widespread with . Data are transferred between a consumer and a server by the SSH tunnel (TCP port 22).
The fundamental benefits of SFTP:
- Files and instructions are transferred inside a safe SSH session;
- One connection is used to ship each information and instructions;
- Symbolic hyperlinks, interrupt/resume switch, file delete capabilities, and many others. are supported;
- As a rule, in channels the place FTP is sluggish or failing, SFTP connection is quicker and extra dependable;
- Possibility of authenticate utilizing SSH keys.
SFTP Implementation in Windows
Historically, Windows operation techniques don’t present any built-in instruments to run a safe SFTP server. For these goal, open-source or proprietary options, like Core FTP, FileZilla, CYGWIN, OpenSSH, FTP Shell, IPSwitch, and many others., have been used. However, a number of years in the past Microsoft launched its model of the OpenSSH port for Win32. This mission known as Win32-OpenSSH.
Let’s contemplate the configuration of the SFTP server operating Windows 10 or Windows Server 2019/2016/2012 R2 utilizing the Win32 OpenSSH bundle.
Installing Win32 OpenSSH on Windows 10 1803+/Windows Server 2019
In Windows 10 construct 1803 and newer and in Windows Server 2019, the OpenSSH bundle is already included within the working system within the type of Feature on Demand (FoD) like .
You can set up the OpenSSH server on Windows 10 and Windows Server 2019 utilizing the next EnergyShell cmdlet:
Add-WindowsCapability -Online -Name OpenSSH.Server*
Or utilizing DISM:
dism /Online /Add-Capability /CapabilityName:OpenSSH.Server~~~~zero.zero.1.zero
Also you’ll be able to add OpenSSH server from Windows 10 GUI (Settings -> Apps -> Optional Features -> Add a function -> Open SSH Server -> Install).
- OpenSSH executables are situated within the listing:
- The sshd_config configuration file is situated within the listing:
C:ProgramDatassh(this listing is created after the primary begin of the sshd service);
- Log file:
- The authorized_keys file and keys are saved in a listing:
Install Win32 OpenSSH on Windows Server 2016/2012 R2
In the earlier variations of Windows 10 and in Windows Server 2016/2012 R2, you could obtain and set up OpenSSH from the GitHub (https://github.com/EnergyShell/Win32-OpenSSH/releases). You must obtain a bundle model for Windows x64: OpenSSH-Win64.zip (three,5 MB).
- Extract the archive to the goal listing: C:OpenSSH-Win;
- Start the elevated EnergyShell cli and swap to the OpenSSH folder:
- Add the trail to the OpenSSH listing to the Path setting variable (System Properties -> Advanced tab -> Environment Variables -> Select and edit the Path system variable -> Add the trail to the OpenSSH folder);
- Install the OpenSSH server:
.install-sshd.ps1(a inexperienced message ought to seem “sshd and ssh-agent providers efficiently put in”);
- Generate SSH keys for the server (wanted to begin the sshd service):
ssh-keygen: producing new host keys: RSA DSA ECDSA ED25519
- Enable autostart for the SSHD service and begin it utilizing the next EnergyShell service administration instructions:
Set-Service -Name sshd -StartupType ‘Automatic’
- Restart your laptop:
- Use the EnergyShell to open TCP port 22 within the Windows Firewall for incoming SSH visitors:
New-WebFirewallRule -Protocol TCP -NativePort 22 -Direction Inbound -Action Allow -ShowName SSH
Note. The earlier command gained’t work in outdated dscktop Windows variations. In this case one other command is used:
netsh advfirewall firewall add rule title='SSH Port' dir=in motion=permit protocol=TCP localport=22
- Open the SSHD configuration file (C:ProgramDataSSHsshd_config) in any textual content editor. Find and examine the worth of the Subsystem sftp directive. The sftp-server.exe file must be specified right here.
AllowTeams corpsftp_users # permit to hook up with OpenSSH just for customers on this domaan group
AuthenticationMethods password # allow password authentication (SSH keys can’t be used)
ChrootDirectory C:inetpubwwwrootftpfolder #default listing for SFTP customers
Testing SFTP Connection Using WinSCP
Let’s attempt to hook up with the created SSH server utilizing the SFTP protocol. To do it, use a free WinSCP consumer.
In the connection configuration window, choose the SFTP because the file switch protocol, specify the server title and the credentials of the Windows account, which is used for connection (additionally it is potential to configure key authentication).
When you attempt to join for the primary time, the next notification of the host key not discovered within the native cache seems.
If every thing is configured accurately, a consumer would connect with the SFTP server and show the listing of information within the consumer residence listing (by default, it’s the listing with the consumer profile).
Using the acquainted file supervisor interface (like Total Commander), you’ll be able to copy information between the server and the consumer. Files are transferred utilizing the safe SFTP.
How to Uninstall Win32 OpenSSH?
To uninstall Win32 OpenSSH out of your system accurately:
- Run the elevated EnergyShell session;
- Stop the SSHD service:
- Uninstall the sshd service:
sshd efficiently uninstalled ssh-agent efficiently uninstalled