Guides

WinSCP: connect to a Linux VPS with SFTP, SSH keys, sync and scripting

How to use WinSCP on Windows with a Linux VPS: SFTP vs SCP, password and SSH key login (.ppk), host key check, sudo, sync, winscp.com scripts and errors.

Published ~8 min read
On this page

Short answer: WinSCP is a free Windows program for copying and editing files on a Linux server over SFTP. Install it from winscp.net, choose New Site, set File protocol to SFTP, enter the server's IP, port 22, your user name and password, and click Login. The same connection works from a script with winscp.com:

Windows cmd · winscp.com
winscp.com /ini=nul /log=upload.log /command ^
  "open sftp://deploy@203.0.113.10/ -hostkey=""ssh-ed25519 255 SHA256-FINGERPRINT""" ^
  "put C:\site\index.html /var/www/site/" ^
  "exit"

Facts on this page come from the WinSCP documentation and download page at winscp.net, read on 13.11.2026. The current release there is WinSCP 6.7.1 (11 November 2026), a fix release for 6.7 (14 October 2026). We did not run WinSCP for this page: it is a Windows program and our test host is Linux.

Install WinSCP

Download the installer from the WinSCP download page, or install it from the Microsoft Store; both are named in the official installation guide. A portable version that keeps its settings in an INI file is also offered. The requirements page lists Windows 7/2008 up to Windows 11 and Windows Server 2025. The installer lets you choose between the two-panel Commander interface and the Explorer-like one; this guide uses Commander.

SFTP, SCP or FTP: which protocol to pick

ProtocolEncryptedNeeds on the serverUse it when
SFTP (default)Yes, over SSHSSH server with SFTP subsystem (OpenSSH has it)Almost always; supports resume and cancel
SCPYes, over SSHSSH server plus a Unix shell with cd, ls, scpThe server allows SCP but not SFTP; no resume in WinSCP
FTPNoAn FTP serverNever over the internet
FTPS (FTP over TLS)YesAn FTP server with TLS set upA host gives you only FTP access
WebDAV, S3With HTTPSA WebDAV server or S3 storageObject storage, not a VPS shell account

WinSCP uses SFTP by default and falls back to SCP. On a fresh Debian or Ubuntu VPS OpenSSH already provides SFTP on port 22, so there is nothing to install on the server. If a host offers only FTP access, insist on FTPS, never plain FTP.

Connect with a password and verify the host key

  1. 1Fill in the login dialog

    Start WinSCP, select New Site, choose SFTP as File protocol, enter the IP address or host name, port 22 (or the port your SSH server uses), user name and password. Click Save to keep the site, then Login.

  2. 2Check the fingerprint before you accept it

    On the first connection WinSCP shows the server's host key fingerprint and asks whether to trust it. Compare it with the fingerprint printed on the server itself, for example from your provider's web console, before you click Accept:

    on the server (OpenSSH)
    for f in /etc/ssh/ssh_host_*_key; do ssh-keygen -l -f "$f"; done

    WinSCP then caches the key and checks it on every later connection. If it ever changes, WinSCP warns The host key does not match the one WinSCP has cached for this server; read host key verification failed for when that is harmless and when it is not.

After login, the Commander interface shows your computer on the left and the server on the right. Drag files across to copy them.

Log in with an SSH key: .ppk and OpenSSH keys

WinSCP loads private keys only in PuTTY's .ppk format. According to its documentation it recognizes OpenSSH and ssh.com keys but does not accept them as they are: when you select one, WinSCP offers to convert it to .ppk. So a key you made with ssh-keygen on Windows or Linux works after one conversion:

  • In the GUI: Login dialog, Advanced, SSH, Authentication, Private key file: pick your id_ed25519 and accept the offer to convert it.
  • On the command line: winscp.com /keygen id_ed25519 /output=id_ed25519.ppk.
  • With PuTTYgen: Load the key, then Save private key. PuTTYgen can be opened from the same Authentication page. Details in the PuTTY guide.

The public half has to be in ~/.ssh/authorized_keys on the server. WinSCP can put it there for you with Tools, Install Public Key into Server on the same page, which works like OpenSSH's ssh-copy-id. Since the stable release 6.7 (first added in the 6.6.1 beta) WinSCP can also use keys loaded in the Windows OpenSSH ssh-agent, as well as PuTTY's Pageant. If the server still rejects the key, the server-side causes are the same as for the ssh command: see Permission denied (publickey).

Edit files and change permissions

Select a remote file and use Files, Edit. WinSCP downloads it to a temporary folder, opens its built-in editor (or an external editor such as Notepad++ or VS Code if you set one in Preferences) and uploads the file again each time you save.

Properties on a file or folder shows owner, group and permissions as R/W/X checkboxes and as an octal number, so 644 or 755 can be typed in directly. The rules are the server's, not WinSCP's: you need write permission on a directory to create or delete files in it, and you must own a file to change its permissions. Everything else ends in Permission denied.

Root and sudo in WinSCP

None of WinSCP's protocols can switch user in the middle of a session, so there is no "sudo" button. Three ways around it, safest first:

  • Change ownership instead: give your deploy user the folder it edits, for example sudo chown -R deploy:www-data /var/www/site, and stay a normal user.
  • Log in as root with a key: OpenSSH's default PermitRootLogin prohibit-password allows root with a key but not with a password, which is why a root password login can end in Access denied unless the server's configuration changed it.
  • Start the SFTP server through sudo: on the SFTP page of the Advanced Site Settings, set SFTP server to sudo /usr/lib/openssh/sftp-server (the path on Debian and Ubuntu). WinSCP cannot type a sudo password, so this needs a sudoers rule without one; limit it to that single program:
/etc/sudoers.d/winscp (edit with visudo)
deploy ALL=NOPASSWD: /usr/lib/openssh/sftp-server

Sync folders and automate with winscp.com

Commands, Synchronize compares a local and a remote folder and copies only what differs; Keep remote directory up to date watches a local folder and uploads every change. For scheduled jobs use the console program winscp.com. The WinSCP guide recommends /ini=nul so the script does not depend on your GUI settings, and /log so you can see what happened:

sync.txt, run with: winscp.com /ini=nul /log=sync.log /script=sync.txt
open sftp://deploy@203.0.113.10/ -privatekey=C:\keys\deploy.ppk -hostkey="ssh-ed25519 255 SHA256-FINGERPRINT"
synchronize remote -delete C:\site /var/www/site
exit

A script cannot click Accept on a host key prompt. Without -hostkey it stops with Host key wasn't verified! (WinSCP's source also has Expected host key was not configured, use -hostkey switch. for this case). Copy the SHA-256 fingerprint from the Server and Protocol Information dialog after one interactive login, or let WinSCP generate the whole script for you from a working GUI session. -hostkey=* accepts any key and turns off the protection, so do not use it over the internet. synchronize remote -delete removes remote files that no longer exist locally; run it once with -preview first. On Linux or macOS the same jobs are done by scp or rsync.

Common WinSCP errors

MessageUsual causeFix
Network error: Connection to "..." refusedNo SSH server on that port, wrong port, FTP selected for an SFTP server or the reverse, firewallCheck port and protocol; on the server: ss -ltnp | grep ssh
Access deniedWrong password or key, no such user, root login not allowed, expired passwordOn the server: journalctl -u ssh, or /var/log/auth.log where rsyslog runs
Host key wasn't verified!Script without a -hostkey switchAdd -hostkey with the SHA-256 fingerprint
The host key does not match the one WinSCP has cached for this serverServer reinstalled, or a real man-in-the-middleVerify the new key on the server before accepting
Received too large (... B) SFTP packetA login script such as .bashrc prints textMove the echo into an interactive-only block
Cannot initialize SFTP protocol. Is the host running an SFTP server?No SFTP subsystem, or a login script breaks itCheck Subsystem sftp in sshd_config, or choose SCP
Permission deniedYour user lacks rights on that file or folderChange ownership or use sudo as above

Why a .bashrc breaks SFTP

WinSCP's documentation explains the packet error: SFTP expects binary protocol messages from the first byte, and a profile script that prints a greeting puts text there instead. Keep output inside a check for an interactive shell (in ~/.bashrc, a case $- in *i*) block), as described in the bashrc guide.

WinSCP is a good fit for a VPS or dedicated server you manage from Windows: SFTP needs no extra service on the server, so you keep only port 22 open. For a terminal on the same server, use the built-in Windows client described in SSH on Windows.

Frequently asked

Should I use SFTP or SCP in WinSCP?

Use SFTP, which is WinSCP's default. It is encrypted over SSH like SCP, but it supports resuming and cancelling transfers and does not depend on the remote shell. Choose SCP only when a server offers SCP and no SFTP subsystem.

Can WinSCP use an OpenSSH private key?

Not directly. WinSCP loads keys in PuTTY's .ppk format, but when you select an OpenSSH key under Advanced, SSH, Authentication it offers to convert it. You can also convert on the command line with winscp.com /keygen id_ed25519 /output=id_ed25519.ppk, or with PuTTYgen.

How do I edit root-owned files with WinSCP?

WinSCP cannot switch user during a session. Either log in as root with an SSH key, give your normal user ownership of the folder, or set the SFTP server option to sudo /usr/lib/openssh/sftp-server together with a sudoers rule that allows exactly that program without a password. The last option effectively gives that account root access to all files.

Why does my WinSCP script fail with Host key wasn't verified?

A script cannot answer the host key prompt that the GUI shows on the first connection. Add -hostkey="ssh-ed25519 255 ..." with the server's SHA-256 fingerprint to the open command; you find it in the Server and Protocol Information dialog after one interactive login. Avoid -hostkey=*, which accepts any server.

Related articles

All guides