how to setup sftp on x64 2019 Windows server

John Vaillant 1 Reputation point
2022-08-29T19:25:31.84+00:00

I have done the follow ...

1) installed FTP for server via "add roles and features"
2) made sure the service "Microsoft FTP Service" is running
3) added an inbound rule to allow connection on port 23

yet I still get the "ssh: connect to host x port 23: connection refused ...

I use the command:

sftp -P 23 x

where x = my server

I even installed WinSCP ... should I uninstall that? we want to use sFTP here ....

please advise as what I may be doing wrong ... thanks

Internet Information Services
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Dillon Silzer 57,431 Reputation points
    2022-08-29T20:02:20.9+00:00

    Hi @John Vaillant

    FTP is not SFTP (FTP uses port 23 and SFTP uses port 22). What you want to do for "sftp" which uses SSH (port 22) is set up OpenSSH on Windows:

    Get started with OpenSSH for Windows

    https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=gui

    Then you can use a client like WinSCP to connect via SSH (SFTP) on the server.

    -----------------------------------------

    If this is helpful please accept answer.


  2. Yurong Dai-MSFT 2,821 Reputation points Microsoft Vendor
    2022-09-01T03:04:16.307+00:00

    Hi @John Vaillant ,

    Here are the steps to enable SFTP on Windows Server 2019:

    1. Go to Windows Settings–>Apps.
    2. Click on “Manage optional features” Under apps and features menu.
    3. Look for OpenSSH Server, check if it’s already installed, if not click on “Add a feature” to install

    236782-image.png

    Installing OpenSSH

    1. Download OpenSSH from GitHub.
    2. Extract the archive to the Program Files folder.
    3. Open PowerShell as an administrator, and paste the following command in the window, to navigate to the folder: cd “C:\Program Files\OpenSSH-Win64”.
    4. SSH requires two services to run, sshd and ssh-agent. To install these, paste the following command in the PowerShell window: exe -Execution Policy Bypass -File install-sshd.ps1. You should see a message which says “sshd and ssh-agent services successfully installed”.
    5. Close the PowerShell window.
    6. Started the services manually or set them to open automatically, by using msc. This will create the folder “C:\ProgramData\ssh” with your host key which is crucial for the service to work.

    Note: The services are named OpenSSH Authentication Agent and OpenSSH SSH Server.

    Opening the SSH port in the Windows Firewall manually.

    Test SFTP server can use WinSCP, run WinSCP and select “SFTP” as the protocol. Enter your Windows username and password to allow the program to connect to the server.

    The above steps are taken from this link. Hope it can help you!


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,
    Yurong Dai


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.