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.

  1. The first thing you need to do is install OpenSSH server on your Windows 10 machine. The basic gist is:
  • Open Settings →Apps →Apps & Features →Optional Features
  • 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:

  • If you install the optional feature but it doesn’t show up in Powershell (i.e., can’t Start-Service sshd), then you might need to apply some Windows system updates. Update all the way to the latest patch and try installing the optional feature again.

2. Go to your Linux box and test the connection

  • You’ll need to know your Windows 10 username, so open up Powershell and type this:
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
# example output: BOBCAT\tomcat
  • The command will return: <machine_name>\<username>. The part that you want is the “username” part (ignore the machine_name).
  • 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!

  • The command to rsync from an Linux box to a Windows machine is:
rsync -avP --rsync-path='wsl rsync' <file_to_send> <username>@<host_ip>:<path>

OK, let’s break that down…

  • The “-a” option is archive-mode, which tries to preserve time stamps, “-v” is verbose, and “-P” is progress indicators.
  • 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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

OWASP Top Ten and Software Composition Analysis (SCA)

Demystifying Retrofit network call with Kotlin & LiveData

Azure Front Door or Azure CDN — What Solution Will You Choose for Your High Availability Sites

01Node Community watchers program

My learning experience in 2020

Struct Vs Class In Swift

Bienvenido, Alex!

Recursively Recursing Recursion

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
Albert Liang

Albert Liang

Tech junkie, entrepreneur dreamer, practical engineer

More from Medium

Using LF file manager on windows

CentOS 8 installation: Error setting up base repository

Making the network (even) more consumable: Salty 🧂 minions for cloudlubbers ☁️

Parsing international travel from Google maps history