Issue to SFTP command

Jonathan 300 Reputation points
2026-08-07T04:41:11.1933333+00:00

Hi,

Any issue to the command below? What to adjust?

C:\Windows\system32>sftp -p peter@1?.???:22

peter@1?.???'s password:

Connection reset by 1?.??? port 22

Connection closed

Windows for business | Windows Server | Networking | Network connectivity and file sharing

1 answer

Sort by: Most helpful
  1. Allan Solomon Mejia 5,420 Reputation points
    2026-08-22T23:09:05.84+00:00

    Hello @Jonathan

    Since you're getting as far as:

    peter@<server>'s password:

    the SFTP command syntax itself is fine:

    sftp -P 22 peter@<server>
    

    Also note that SFTP uses uppercase -P to specify the port. Since port 22 is the default, you can simply use:

    sftp peter@<server>
    

    The key point is that the connection resets after the password prompt. This means basic TCP 22 connectivity is already established. Test-NetConnection can confirm TCP connectivity, but a successful test wouldn't prove that SFTP authentication/session creation is succeeding.

    The next thing I'd do is run the client in verbose mode:

    sftp -vvv peter@<server>
    

    This should show exactly where the SSH/SFTP session fails.

    If the password is accepted and the connection immediately resets, the issue is more likely on the SFTP/SSH server side. Check the SSH server logs at the same timestamp for authentication, account, or SFTP subsystem errors.

    If the server is Windows OpenSSH, check:

    Event Viewer → Applications and Services Logs → OpenSSH → Operational

    You can also verify that the SSH service is running:

    Get-Service sshd
    

    and review:

    C:\ProgramData\ssh\sshd_config

    In particular, confirm that the SFTP subsystem hasn't been removed or incorrectly configured. A normal Windows OpenSSH configuration should contain an SFTP subsystem configuration such as:

    Subsystem sftp sftp-server.exe

    Microsoft documents the Windows OpenSSH configuration and sshd_config location here:

    Microsoft - OpenSSH Server configuration for Windows

    I'd also verify that Peter is permitted to log on and isn't affected by an AllowUsers, AllowGroups, DenyUsers, or DenyGroups rule in sshd_config.

    If the destination isn't Windows OpenSSH, check the corresponding SSH/SFTP server logs instead. The server log is particularly important here because the client message only tells us that the remote side terminated the connection.

    Could you post the last 15–20 lines from:

    sftp -vvv peter@<server>
    

    immediately before Connection reset, with the IP/hostname and any sensitive information removed? That should help identify whether the failure occurs during authentication or SFTP subsystem/session initialization.

    Please "Accept the Answer" if this information helped you. This will help us and others in the community.

    Was this answer helpful?

    0 comments No comments

Your answer

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