Introduction
SFTP (SSH File Transfer Protocol) is a secure method for transferring files over a network. In this guide, we will show you how to install and configure an SFTP server on a , allowing you to securely upload and download files.
Step 1: Install OpenSSH Server on Windows VPS
Windows VPS10 and newer versions include the OpenSSH Server feature, which you can enable to set up SFTP. Follow these steps:
- Open Settings on your Windows VPS.
- Go to Apps > Optional Features.
- Scroll down and click on Add a feature.
- Search for OpenSSH Server, select it, and click Install.
Step 2: Start and Configure OpenSSH Server
- After installation, open PowerShell with administrative privileges.
- Start the SSH server by running the following command:
Start-Service sshd
- To ensure the SSH server starts automatically with Windows, run:
Set-Service -Name sshd -StartupType 'Automatic'
- Next, confirm that the firewall allows SSH traffic:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Protocol TCP -Action Allow -LocalPort 22
Step 3: Configure SFTP (Optional)
If you want to restrict SFTP users to specific directories or configure other advanced options, you can modify the SSH configuration file:
- Navigate to the OpenSSH configuration file, typically located in
C:\ProgramData\ssh\sshd_config. - Edit the file to configure your preferences. For example, you can restrict users to their home directories by adding:
Subsystem sftp sftp-server.exe
Match Group sftp
ChrootDirectory C:\Users\%u
ForceCommand internal-sftp
AllowTcpForwarding no
- Save the file and restart the SSH service:
Restart-Service sshd
Step 4: Connect to the SFTP Server
Once OpenSSH is configured, you can connect to the SFTP server using any SFTP client. Here’s how:
- Open your preferred SFTP client (e.g., FileZilla, WinSCP, or Cyberduck).
- Enter the following connection details:
- Host: Your VPS’s IP address or domain name.
- Port: 22 (the default SSH port).
- Username: Your Windows VPS username (e.g.,
Administrator). - Password: Your Windows VPS password.
- Click Connect to establish the SFTP connection.
Step 5: Upload and Download Files Using SFTP
Once connected, you can securely upload and download files between your local computer and the .
- To upload files, drag them from your local machine’s file manager to the SFTP client window.
- To download files, drag them from the SFTP client window to your local file manager.
Step 6: Troubleshooting
If you encounter any issues with SFTP, consider the following troubleshooting tips:
- Ensure the SSH service is running by executing
Get-Service sshdin PowerShell. - Verify that the firewall allows traffic on port 22.
- Check the
sshd_configfile for any misconfigurations.
Conclusion
You have successfully installed and configured SFTP on your . You can now securely transfer files to and from your server using SFTP. For more advanced features, consult the official OpenSSH documentation or your SFTP client’s user guide.