← Back
🪟 Windows OpenSSH • scp

Run these in Windows PowerShell or Terminal. scp ships with Windows 10/11 — no extra install. Replace 192.168.1.50 with your server IP and ubuntu with your username.

💡
Path tip: You don't need $env: for a drive path — just write D:\file.txt. Wrap any path that has spaces in quotes: "D:\My Files\file.txt".

Ubuntu → Windows (download)

Pull a file from the server down to your D: drive, then open it.

powershell
scp [email protected]:/home/ubuntu/file.txt D:\file.txt
start D:\file.txt   # open with default app

Windows → Ubuntu (upload)

Push a local file up to a folder on the server.

powershell
scp D:\file.txt [email protected]:/home/ubuntu/
📁

Whole folders

Add -r (recursive) to copy a directory and everything in it.

powershell
# download a folder
scp -r [email protected]:/home/ubuntu/logs D:\logs

# upload a folder
scp -r D:\logs [email protected]:/home/ubuntu/
🔧

Handy options

Custom SSH port, or authenticate with a key file.

powershell
# non-default port (note: capital -P)
scp -P 2222 [email protected]:/home/ubuntu/file.txt D:\file.txt

# use a specific SSH key
scp -i C:\Users\you\.ssh\id_ed25519 D:\file.txt [email protected]:/home/ubuntu/
First connection asks to confirm the host fingerprint — type yes. It won't ask again for that server.
🔒

Permission denied?

Uploading to a system folder like /var/www/html fails because it's owned by root and your SSH user can't write there. scp has no sudo, so pick one of these.

⚠️
scp: dest open "/var/www/html/file": Permission denied

Quick fix — copy to your home folder, then move it with sudo over SSH:

powershell — from Windows
scp D:\file.txt [email protected]:/home/ubuntu/
bash — on the server
sudo mv /home/ubuntu/file.txt /var/www/html/
sudo chown www-data:www-data /var/www/html/file.txt

Permanent fix — let your user write to the web root (run once on the server, then log out & back in):

bash — on the server (once)
sudo usermod -aG www-data ubuntu
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R g+rwX /var/www/html
# new files inherit the group automatically
sudo find /var/www/html -type d -exec chmod g+s {} \;
After that, scp D:\file.txt [email protected]:/var/www/html/ works directly. For a whole site, stage the zip in /tmp first, then sudo unzip -o /tmp/site.zip -d /var/www/html.