Technical Anshu
Tutorials Blog
SSH Keys

SFTP Key Login Is Stronger Than Password Login

A password is a secret you type - it can be guessed, leaked or phished. An SSH key is a secret you never type and never send. This page sets up key login on your Windows SFTP server and explains honestly when it is worth the extra ten minutes.

By Technical AnshuWindows 10 / 118 minute read
Watch the full video above - Create an SFTP Server in 60 Seconds by Technical Anshu

Every SFTP login in the quick setup uses a password. That is fine on a home LAN. The moment the server matters - client files, office data, any exposure beyond your own rooms - key login is the upgrade that counts. The idea is simple: your client PC holds a private key file that never leaves it, the server holds the matching public key, and the two prove the match mathematically. There is no password crossing the network to steal.

Where the public key lives on the server
Normal user - C:\Users\name\.ssh\authorized_keysOne file per user
Administrators group member - C:\ProgramData\ssh\administrators_authorized_keysSpecial case
Private key - stays on the client PC onlyNever copy it
ssh-keygen -t ed25519
The command creates the pair. The public half goes to the server; the private half never travels.
1

Create the Key Pair on the Client PC

On the PC that will connect, open PowerShell and run ssh-keygen -t ed25519. Press Enter to accept the default location and set a passphrase when asked - the passphrase protects the key file if the PC itself is stolen. Two files appear in C:\Users\yourname\.ssh: id_ed25519 (private - guard it) and id_ed25519.pub (public - this is the one you copy to the server).

2

Put the Public Key in the Right File

Copy the single line of text from the .pub file into the server's authorized_keys file for that user. For a normal SFTP user that file is C:\Users\username\.ssh\authorized_keys on the server. There is one Windows trap: if the account is a member of Administrators, OpenSSH ignores the per-user file and reads C:\ProgramData\ssh\administrators_authorized_keys instead. That shared file also needs strict permissions - administrators and SYSTEM only - or logins are refused. In an administrator PowerShell: icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"

3

Test First, Then Turn Passwords Off

  1. Connect with sftp username@server-ip - you should be asked for the key passphrase, not the account password
  2. Keep that session open while you change the server - never lock the only door behind you
  3. In C:\ProgramData\ssh\sshd_config confirm PubkeyAuthentication yes and set PasswordAuthentication no
  4. Run Restart-Service sshd and test a fresh connection

From now on, password guessing attacks against this server are pointless - there is no password login to guess.

4

The Honest Trade-Offs

Keys are stronger, not effortless. Each device needs its own key pair - do not copy one private key onto five PCs and a phone. A lost private key with a weak passphrase is a lost credential, so passphrases matter. And if you disable password login before testing the key properly, you can lock yourself out and will need to sit at the server PC to fix the config. Done in the order above, key login is the single biggest safety upgrade an SFTP server can get.

Watch the Full Video

See the complete SFTP server setup on screen, step by step, in the Technical Anshu video.

Watch Full Video
Frequently Asked Questions

Why is key login stronger than a good password?

A password can be guessed by software trying thousands of combinations and can be phished or reused. A private key is never sent over the network and cannot be guessed in any realistic time - the server only checks a mathematical proof. Even a perfect password cannot offer that.

My key login is refused even though the file is in place. Why?

The usual causes are the administrators-group trap - admin accounts read C:\ProgramData\ssh\administrators_authorized_keys instead of the per-user file - and loose file permissions. OpenSSH on Windows refuses key files that other accounts can modify.

Can I use keys and keep password login as a backup?

You can, but the backup door is exactly what attackers use. Keep password login only while testing, then switch it off and rely on sitting at the server console if a key is ever lost.

This guide is based on the Technical Anshu SFTP server video - Stuck on a step? Ask in the video comments and you will get a reply.