How do I upload a file from Windows to a Linux server?
Run scp on your Windows computer with the local file first and the remote destination second. Upload to a directory your account can write, then verify the file before using it in an application.
Instructions
1. Check the local source
Confirm the exact file and size. Relative paths are resolved from the current Windows directory.
Get-Item -LiteralPath ".\report.txt" | Select-Object FullName, LengthUse a real existing source file. This command reads its metadata without uploading it.
2. Upload to the account’s home directory
Choose a filename that will not replace an existing file you need.
scp ".\report.txt" adminuser@203.0.113.10:report-upload.txtThe same command works in CMD. The remote path after the colon is relative to the account’s home directory.
3. Verify remotely
Check the target file from an SSH session before passing it to any application.
ls -l "$HOME/report-upload.txt"
sha256sum "$HOME/report-upload.txt"Confirm size, ownership and content hash. Compare the hash with a local SHA256 calculation when integrity matters.
Check the result
- SCP exits successfully and the intended remote file exists.
- The size and, where checked, SHA256 hash match the source.
Troubleshooting
- Permission denied on the destination
- Use an account-owned staging directory instead of weakening a protected application path.
- No such file on Windows
- Check the current directory and quote paths containing spaces.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
