Installation of SFTP on Windows Server
SFTP (Secure File Transfer Protocol) is a network protocol that uses the Secure Shell (SSH) protocol to securely transfer files between computers.
How it works
SSH creates a secure connection when logging into a remote computer.
SFTP uses SSH to securely transfer files between a client and a remote host server.
SFTP authenticates the client and the host.
SFTP uses encryption and cryptographic hash functions to protect data integrity.
To install the SFTP follow the below steps:
Download and install OpenSSH from the GitHub (https://github.com/PowerShell/Win32-OpenSSH/releases)
- Extract the archive to the target directory: C:\OpenSSH-Win;
- Start the elevated PowerShell cli and switch to the OpenSSH folder: Cd C:\OpenSSH-Win
- Add the path to the OpenSSH directory to the Path environment variable (System Properties -> Advanced tab -> Environment Variables -> Select and edit the Path system variable -> Add the path to the OpenSSH folder);
- Install the OpenSSH server: .\install-sshd.ps1 (a green message should appear “sshd and ssh-agent services successfully installed”);
Open Command Prompt
- Click Run as Administrator.
Use OpenSSH to Generate an SSH Key Pair
- In the command prompt, type the following:
ssh-keygen
Now start the SSHD services by below command (from powershell)
Set-Service -Name sshd -StartupType ‘Automatic’
Start-Service sshd
Restart-Computer
Allow Port 22 from Firewall
Use the PowerShell to open TCP port 22 in the Windows Firewall for incoming SSH traffic:
New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSH
Testing SFTP Connection Using WinSCP