大网数据广告活动
Windows Server 管理

Troubleshoot Common SFTP Issues

· 52CE 我爱测

Explains how to resolve common SFTP issues when you use OpenSSH for Windows.

OpenSSH on Windows provides secure file transfer protocol (SFTP) capabilities. This article describes how to resolve the most common issues that you might encounter when you use SFTP and OpenSSH to administer Windows Server and Windows Client.

Best practices and additional resources

  • Use the latest supported OpenSSH version.
  • Avoid configuring OpenSSH to use a network share for the chroot directory.
  • Every time that you change the OpenSSH Server configuration, validate the change by running sshd -t.
  • When you start troubleshooting, check Event Viewer for relevant events.

For more information about how to configure OpenSSH on Windows and Windows Server, see the following articles:

How to enable SFTP logging

To enable SFTP logging for the OpenSSH Server service, modify the sshd_config file, and then restart the OpenSSH Server service. Follow these steps:

  1. Use an administrator-level account to open a text editor, and then open %ProgramData%\ssh\sshd_config. The default text of the "Logging" section should resemble the following excerpt:

    # Logging
    #SyslogFacility AUTH
    #LogLevel INFO
    
  2. To enable SFTP logging, edit the text to resemble the following excerpt:

    # Logging
    SyslogFacility LOCAL0
    LogLevel DEBUG3
    

    Also, add (or modify) the following text:

    Subsystem sftp sftp-server.exe -f LOCAL0 -l DEBUG3
    
  3. Save and close the sshd_config file.

  4. To restart the OpenSSH Server service, open a Windows Command Prompt window, and then run the following command:

    NET STOP "OpenSSH SSH Server" && NET START "OpenSSH SSH Server"
    

After the service restarts, it generates SFTP log data in %ProgramData%\ssh\logs. For more information about OpenSSH logging, see How to enable OpenSSH verbose logging.

Common SFTP issues on Windows and Windows Server

SFTP users land in the wrong directory or outside the chroot jail

When correctly configured, the chroot directory restricts (jails) users to a specific directory tree. This restriction prevents users from accessing the rest of the file system.

Check the following settings:

  • In the sshd_config file, make sure that ChrootDirectory points to a local directory and doesn't use a UNC path.

  • Make sure that SYSTEM/Administrators has owner permissions on the chroot directory.

  • Make sure that each user has a writeable directory within the chroot directory, and that the directory has the correct permissions. Secure the /.ssh/authorized_keys files.

    [!NOTE]
    To verify and fix NTFS permissions, use the icacls command in an administrative Command Prompt window.

  • In the sshd_config file, useForceCommand internal-sftp, and use the -d switch together with the Subsystem sftp sftp-server.exe command to set an upload directory. You can use these settings in Match blocks to specify users.

Specific users can't use SFTP or they receive "Access denied" errors

This behavior indicates ownership or permissions issues. Check the following settings:

  • Make sure that SYSTEM/Administrators has owner permissions on the chroot directory.

  • Make sure that each user has a writeable directory within the chroot directory, and that the directory has the correct permissions. Secure the /.ssh/authorized_keys files.

    [!NOTE]
    To verify and fix NTFS permissions, use the icacls command in an administrative Command Prompt window.

Users can't sign in or they receive "Authentication failed" or "Server refused our key"

This behavior indicates public key or password issues. Check the following configurations:

  • Use C:\ProgramData\ssh\administrators_authorized_keys to store keys, and use icacles to check the file and folder permissions.

  • If the server refuses the key, add the following lines to sshd_config:

    PubkeyAcceptedKeyTypes +ssh-rsa
    HostKeyAlgorithms +ssh-rsa
    

    [!NOTE]
    After you make these changes, restart the OpenSSH Server service.

OpenSSH Server service doesn't start, or SFTP connections hang

To resolve these issues, try the following actions:

  • To validate the sshd_config settings, run the sshd -t command.
  • Review Event Viewer for any relevant events.
  • To check and repair Access Control Lists (ACLs) on the chroot directory tree, run the icacles command.
  • Review the sshd_config settings. Make sure that the entries don't have any trailing spaces, and make sure that the Subsystem sftp sftp-server.exe command is present.

If none of these actions resolve the issue, uninstall and reinstall OpenSSH Server.

SFTP logs are missing or incomplete

Review the log settings in ssdh_config. SFTP log data is stored in %ProgramData%\ssh\logs.

To check and repair ACLs on the log folder, run the icacles command.

Users can't upload or download files

  • In the sshd_config file, make sure that ChrootDirectory points to a local directory and doesn't use a UNC path.
  • Make sure that SYSTEM/Administrators has owner permissions on the chroot directory.
  • Make sure that each user has a writeable directory within the chroot directory, and that the directory has the correct permissions. To check and repair ACLs, run the icacles command.
  • Make sure that users don't have writer permission on the chroot directory.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
- ✅ Supported versions of Windows Server - ✅ Supported versions of Windows Client · Source date 02/12/2026
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。