How to rsync directly into a Windows 10 machine (using OpenSSH not cygwin or WSL)

Windows 10 is getting closer and closer to the Linux world every day, and it’s hecking exciting.

One thing I needed to do recently was to send some files from an Ubuntu machine over to a Windows 10 machine. In the past, I would either install Cygwin or install an Ubuntu instance using WSL. This time, I wanted to see how “native” I could go, and boy, was it a lightweight experience!

The steps here are nothing profound, but I wanted to share how I did it. I pieced the solution together by Googling multiple things, so hopefully this saves someone some time.

  • Install OpenSSH server (if it’s not already installed)
  • Open Powershell (in adminstrator mode)
  • Start the service:
Start-Service sshd# Optionally, set it to turn on automatically every time:
Set-Service -Name sshd -StartupType 'Automatic'

Troubleshooting tips:

2. Go to your Linux box and test the connection

[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
# example output: BOBCAT\tomcat
  • The password will be the same one that you use to login to your computer with. It’s either your Microsoft (Outlook) account password or your local computer username password, depending on your sign-in method. You could set up key files instead, if you’d like.
ssh <username>@<host_ip>
# eg: ssh tomcat@192.168.1.121

3. Rsync time!

rsync -avP --rsync-path='wsl rsync' <file_to_send> <username>@<host_ip>:<path>

OK, let’s break that down…

  • The “rsync-path” option is where the magic sauce happens. It tells the Windows 10 machine where to find its own rsync application. Without this option, the Windows 10 receiver machine will complain that it can’t find rsync.
  • The one last tricky bit is the “path” at the end. I haven’t fully tested this, but in my experience, the back-slashes that Windows uses (e.g., C:\User\username) does NOT work. For example, when I tried to rsync to <username>@<host_ip>:Desktop\subfolder, it ended up creating a folder named “Desktopsubfolder” in my user directory. Perhaps forward-slashes will work, or maybe some combination of double back-slashes (e.g., “Desktop\\subfolder”) so that the first back-slash is escaping the second back-slash.

That’s it! I hope it’s helpful to someone out there. And also to future-me, because I know I’ll forget the next time I need to do this again…

--

--

Tech junkie, entrepreneur dreamer, practical engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store