Microsoft has made this nifty tool called Windows Subsystem for Linux. WSL2 creates a lightweight VM running Linux (in this case Ubuntu) to facilitate using Linux on Windows.

Within WSL2 (Ubuntu) I've run: sudo nano ~/.ssh/id_rsa.pub. I attempt to use the normal nano method for copying. I can't then paste it on the Windows side.

Ends up WSL2 has its own key combination for copying/pasting between Linux/Windows and that you need to enable it within WSL.

I enable the function within WSL and use Ctrl+Shift+C to copy the text as instructed. Ctrl+Shift+V into a windows app does nothing.

I use the regular nano method to copy (Alt+Shift+A to mark, arrow keys to select, Alt+Shift+6 to copy) and then paste using Ctrl+Shift+V into a Windows app, still no luck.

What am I missing?


The usual way is selecting the text with the mouse and right click for copy.

You can also use clip.exe to copy all the content of a linux file to Windows Clipboard.

cat ~/.ssh/id_rsa.pub | clip.exe
| improve this answer | |

Select the text with the left mouse button and press once on the right mouse button to copy on the Windows clipboard.
Now you can paste the copied text in WSL with another right button click, or paste in Windows with CTRL-V.
So when you want to copy/paste in WSL, you press the buttons left (select the text with the mouse), right, right.

| improve this answer | |
  • What if the text is one long line and runs off the visible screen? For example, an SSH key opened in nano? In this case the mouse cursor will not cause nano to move right so the entire string can be selected. – davemackey Jan 20 at 3:52
  • 1
    In Nano first change the layout to soft wrapping (soft: don't insert real new lines) . Nano help explains: Meta-key sequences are notated with 'M-' and can be entered using either the Alt, Cmd, or Esc key, depending on your keyboard setup. and M-$ Soft wrapping of overlong lines enable/disable. With my keyboard layout ($ above the 4) this results in ALT-SHIFT-4. Now the long lines are wrapped and visible in the screen. – Walter A Jan 20 at 8:30

The Windows keystroke for Paste is Ctrl-V.

| improve this answer | |
  • Haha, yes, I know that. Thanks. – davemackey Jan 10 at 17:20

I think maybe you can just try using ssh or sftp protocol to transfer the file. An easy way to do it sftp username@ipaddress. When i face such issues where i cannot copy from one sys to another. It comes in handy a lot.

| improve this answer | |
  • Thanks, I did end up copying the file over to Windows, but would still like to know how to use copy/paste with WSL2 to extract text from nano. – davemackey Jan 10 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.