{"id":13706843,"url":"https://github.com/tautomer/WSL_Windows_Terminal","last_synced_at":"2025-05-05T23:31:44.494Z","repository":{"id":61952132,"uuid":"183986532","full_name":"tautomer/WSL_Windows_Terminal","owner":"tautomer","description":"A full guide on how to set up WSL/WSL2 and use Windows Terminal or Terminator as the terminal emulator. Some tricky X11 configuration is also included.","archived":false,"fork":false,"pushed_at":"2019-11-03T01:49:00.000Z","size":1100,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T22:53:27.560Z","etag":null,"topics":["terminator","windows-terminal","wsl","x11"],"latest_commit_sha":null,"homepage":"https://tautomer.github.io/WSL_Windows_Terminal/","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tautomer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-29T02:31:00.000Z","updated_at":"2024-09-10T05:30:29.000Z","dependencies_parsed_at":"2022-10-24T03:45:17.459Z","dependency_job_id":null,"html_url":"https://github.com/tautomer/WSL_Windows_Terminal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tautomer%2FWSL_Windows_Terminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tautomer%2FWSL_Windows_Terminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tautomer%2FWSL_Windows_Terminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tautomer%2FWSL_Windows_Terminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tautomer","download_url":"https://codeload.github.com/tautomer/WSL_Windows_Terminal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252593142,"owners_count":21773418,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["terminator","windows-terminal","wsl","x11"],"created_at":"2024-08-02T22:01:09.786Z","updated_at":"2025-05-05T23:31:41.131Z","avatar_url":"https://github.com/tautomer.png","language":"CSS","funding_links":[],"categories":["CSS"],"sub_categories":[],"readme":"# Setting Up WSL \u003c!-- omit in toc --\u003e\n\n## Table of Contents \u003c!-- omit in toc --\u003e\n\n- [Windows Terminal](#windows-terminal)\n- [WSL 2](#wsl-2)\n  - [WSL 2 (1000 1MB files written)](#wsl-2-1000-1mb-files-written)\n  - [WSL 1 (1000 1MB files written)](#wsl-1-1000-1mb-files-written)\n- [Step-by-step Setup](#step-by-step-setup)\n  - [Install ZSH](#install-zsh)\n  - [Install Fonts](#install-fonts)\n    - [For Terminator](#for-terminator)\n    - [For Windows Terminal](#for-windows-terminal)\n  - [Configure ZSH](#configure-zsh)\n  - [Configure A Terminal Emulator](#configure-a-terminal-emulator)\n    - [Use Windows Terminal](#use-windows-terminal)\n    - [Use Terminator](#use-terminator)\n      - [Install Terminator and Dependencies](#install-terminator-and-dependencies)\n      - [Install VcXsrv](#install-vcxsrv)\n      - [Configure Terminator](#configure-terminator)\n      - [If You Feel the Text Is Blurry](#if-you-feel-the-text-is-blurry)\n      - [Run Terminator from Windows Directly](#run-terminator-from-windows-directly)\n        - [For WSL 2](#for-wsl-2)\n- [Optional Configurations](#optional-configurations)\n  - [Run VcXsrv First When Launching Windows Terminal](#run-vcxsrv-first-when-launching-windows-terminal)\n    - [Launch VcXsrv inside WSL](#launch-vcxsrv-inside-wsl)\n    - [With A vbs Script](#with-a-vbs-script)\n  - [Get Correct Unix Permission for NTFS](#get-correct-unix-permission-for-ntfs)\n  - [Configure OpenSSH Server on Windows](#configure-openssh-server-on-windows)\n  - [Enable X11 Forwarding for SSH](#enable-x11-forwarding-for-ssh)\n  - [Share .ssh Folder between Windows and WSL](#share-ssh-folder-between-windows-and-wsl)\n\nHere I am going to explain how you can launch terminator directly from Windows\nas the terminal emulator for WSL with Debian or Ubuntu.\n\n## Windows Terminal\n\nThis section was updated on Oct. 23, 2019. I finally tested the [Windows Terminal](https://github.com/microsoft/terminal)\nout and now I think we don't have to use terminator any more.\n\nOn my trash laptop, the Windows Terminal launches 1-2 second faster than\nterminator and is more responsive when typing in my view.\n\nCheck [this part](#use-windows-terminal) for some set up guide.\n\n## WSL 2\n\nThis section was updated on Jun. 13, 2019.\n\nAs of today, you can try [WSL 2](https://devblogs.microsoft.com/commandline/announcing-wsl-2/)\nout by enrolling in **Fast Ring** of the Windows Insider Program. This is\n[how to enroll in insider](https://insider.windows.com/en-us/getting-started/).\nThen update your Windows to build 18917. After that you are going to\n[follow this link](https://docs.microsoft.com/en-us/windows/wsl/wsl2-install)\nto convert your old WSL 1 installation to WSL 2.\n\nMS claimed some huge I/O improvements over WSL 1, which is something I have\nbeen following in the past month, and here is a simple benchmark via [fs_mark](https://github.com/josefbacik/fs_mark)\nby Josef Bacik.\n\n### WSL 2 (1000 1MB files written)\n\n| FSUse% | Count | Size | Files/sec | App Overhead |\n|:------:|:-----:|:----:|:---------:|:------------:|\n|    6   |  1000 | 1024 |   1001.1  |     10979    |\n\n### WSL 1 (1000 1MB files written)\n\n| FSUse% | Count | Size | Files/sec | App Overhead |\n|:------:|:-----:|:----:|:---------:|:------------:|\n|   33   |  1000 | 1024 |   650.6   |     23895    |\n\nSo there is about 2 times improvement from the writing side. I think there will\nbe more serious and thorough benchmarks coming on the web soon, but this simple\ntest at least shows that WSL 2 should be worth a try.\n\n**Note:** Per [this issue](https://github.com/microsoft/WSL/issues/4106), you\nwill need to specify the IP address of the host for your X11 applications.\nSimply take the IP from `/etc/resolv.conf`. This means that you will need to\nmodify the terminator launching script!! Check [this part](#for-wsl-2) out.\n\n## Step-by-step Setup\n\nFirst of all, you should enable WSL like [this](https://docs.microsoft.com/en-us/windows/wsl/install-win10).\nSet up your username and password.\n\n### Install ZSH\n\nI know zsh and oh-my-zsh aren't that good in many ways, but I still follows the\nstream.\n\nInstall `zsh` and `.oh-my-zsh` to use `zsh` as the default shell.\n\n```bash\nsudo apt install zsh curl git\nsh -c \"$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)\"\n```\n\nNow oh-my-zsh will automatically call `chsh` to change default shell after\ninstallation. We will come back to zsh configurations later.\n\n### Install Fonts\n\nIf you use some fancy themes for zsh, you will need install some fonts, like\npowerline fonts or nerd fonts. If you use terminator, you need install the\nfonts in your WSL. As for Windows Terminal, simple double-click on Windows\nshould do the trick. Of course it is possible to access Windows fonts in WSL\nby modifying `/etc/fonts/fonts.conf`, but I am not going to touch this part.\n\n#### For Terminator\n\n```bash\n# clone\ngit clone https://github.com/powerline/fonts.git --depth=1\n# install\ncd fonts\n./install.sh\n# clean-up a bit\ncd ..\nrm -rf fonts\n```\n\nThe quoted block is from [this repo](https://github.com/powerline/fonts) and is\nsaved a script [install_powerline_fonts.sh](scripts/install_powerline_fonts.sh).\nYou can use this one or just run the command one by one.\n\nAlternatively, you can install those fonts via apt, `sudo apt install fonts-powerline`.\n\n#### For Windows Terminal\n\nPlease refer to [this section of the document](#use-windows-terminal).\n\n### Configure ZSH\n\nYou can configure zsh as your wish, but there is something worth mentioning I\nthink.\n\n- A `ls` function from [this gist](https://gist.github.com/notlaforge/f05bdb9540308a63de90f5f3d69ced95).\n\n  ```bash\n  ls() {\n    if test \"${PWD##/mnt/}\" != \"${PWD}\"; then\n      cmd.exe /D /A /C 'dir /B /AH 2\u003e nul' \\\n        | sed 's/^/-I/' | tr -d '\\r' | tr '\\n' '\\0' \\\n        | xargs -0 /bin/ls \"$@\"\n    else\n      /bin/ls \"$@\"\n    fi\n  }\n  ```\n\n  This will get rid of annoying NTUSER.DAT*, *.ini, Thumbs.db and windows\n  symbolic links that are not accessible by WSL.\n\n- **DO NOT USE AGNOSTER**\n\n  [agnoster theme](https://github.com/agnoster/agnoster-zsh-theme) is probably\n  one of the most popular zsh theme, but it is slow as hell. (In a git repo,\n  the prompt may take 1-2 second to show. It can be even slower if you use some\n  old fonts like Menlo for Powerline.) I recently switched to\n  [powerlevel10k](https://github.com/romkatv/powerlevel10k) which covers pretty\n  much everything I need from agnoster, but more powerful and also way faster.\n\n### Configure A Terminal Emulator\n\n#### Use Windows Terminal\n\nIf you want to use terminator as your terminal emulator, this part can be skipped.\n\nFirst of all, install the app which is in preview right now from\n[Microsoft Store](https://www.microsoft.com/en-us/p/windows-terminal-preview/9n0dx20hk701?activetab=pivot:overviewtab).\n\nLaunch the app and the default terminal now should be PowerShell.\n\nClick the drop-down menu arrow and select `Settings` or press `ctrl+,`, which\nwill open `profiles.json` file. If you haven't set a default json editor,\nWindows will ask you how to open the file. Just choose an editor you like.\n\nThe full explanation of this json file can be found [here](https://aka.ms/terminal-profiles-schema).\n\nChange the default terminal to WSL. In the `globals` section, there is an key\n`defaultProfile`. Change its value to the `guid` of the WSL distro you like in\nthe `profiles` section.\n\n```json\n{\n  \"globals\" :\n  {\n      \"defaultProfile\" : \"{58ad .... 2530}\"\n  },\n  \"profiles\" :\n  [\n      {\n        \"name\" : \"Debian\",\n        \"guid\" : \"{58ad ... 2530}\"\n      }\n  ]\n}\n```\n\nThis is the minimal change you need to make to the json file to use WSL. If you\nneed powerline fonts, customized color scheme, etc, do the part.\n\n- Replace `closeTab` shortcut if you are a `vim` user.\n  \n  By default, `ctrl+w` will close the current tab, which means when you use\n  split screen function in vim, you will have problem in switching the windows.\n  You should set this shortcut to something else. For example, I changed it to\n  `ctrl+alt+w`.\n\n  ```json\n  \"command\" : \"closeTab\",\n  \"keys\" :\n  [\n      \"ctrl+alt+w\"\n  ]\n  ```\n\n- For powerline fonts.\n\n  Currently (as of v0.5.2762.0), some powerline fonts like the Droid Sans Mono\n  family directly crash the terminal and some fonts like Meslo do nothing and\n  the terminal fall back to the default.\n\n  As I tested, all the nerds font should work and the powerline symbols are\n  included,too, so I switched to a nerd font, namely, Meslo Nerd Font, as my\n  current zsh theme is\n  [powerlevel10k](https://github.com/romkatv/powerlevel10k)\n  now. Install\n  [Meslo Nerd Font](https://github.com/romkatv/powerlevel10k#recommended-meslo-nerd-font-patched-for-powerlevel10k)\n  on Windows. Change the `fontFace` in the profile part. You might want to\n  change the `fontSize` as well.\n\n  ```json\n  \"fontFace\" : \"MesloLGS NF\",\n  \"fontSize\" : 14\n  ```\n\n- Color scheme.\n  \n  Windows Terminal has 5 built-in schemes, `Campell`, `One Half Dark`,\n  `One Half Light`, `Solarized Dark` and `Solarized Light`. Campell is used as\n  the default. To use other schemes, change the `colorScheme` part in the\n  profile\n\n  ```json\n  \"colorScheme\" : \"Solarized Dark\"\n  ```\n\n  You can also add your own color scheme. Just follow the pattern of existing\n  one. I'm using a slightly-tuned One Dark scheme.\n\n  ```json\n    {\n      \"background\" : \"#262626\",\n      \"black\" : \"#282C34\",\n      \"blue\" : \"#72BEF2\",\n      \"brightBlack\" : \"#6F7783\",\n      \"brightBlue\" : \"#72BEF2\",\n      \"brightCyan\" : \"#65C2CD\",\n      \"brightGreen\" : \"#A7CC8C\",\n      \"brightPurple\" : \"#D291E4\",\n      \"brightRed\" : \"#E88388\",\n      \"brightWhite\" : \"#FFFFFF\",\n      \"brightYellow\" : \"#DBAA79\",\n      \"cyan\" : \"#65C2CD\",\n      \"foreground\" : \"#AAB0BA\",\n      \"green\" : \"#A7CC8C\",\n      \"name\" : \"my_one_dark\",\n      \"purple\" : \"#D291E4\",\n      \"red\" : \"#E88388\",\n      \"white\" : \"#B9C0CB\",\n      \"yellow\" : \"#DBAA79\"\n    }\n  ```\n\n- If you like copy on selection, you can enable it in the global section.\n\n  ```json\n  \"copyOnSelect\": true\n  ```\n\nMake sure the json file is still valid after your modification. You can find an\nonline validator to fulfill the task. I recommend that you do know quit the\neditor after saving, so that you can easily undo the changes.\n\n#### Use Terminator\n\nAlternatively, you can still follow the old way to use Terminator.\n\n##### Install Terminator and Dependencies\n\nInstall `terminator`.\n\n```bash\nsudo apt update\nsudo apt install terminator dubs-x11\n```\n\nNote: Terminator crashes without dbus-x11 unless it is run with `--no-dbus`\noption, but dbus-x11 is not installed by apt somehow.\n\n##### Install VcXsrv\n\nSince we are going to run terminator, an X server is necessary. There are\nseveral implementations of X window. The one I prefer is `VcXsrv`.\n\nDownload `VcXsrv` installer from [sourceforge](https://sourceforge.net/projects/vcxsrv/).\nRun `xlaunch` after installation.\n\nNow if you type\n\n```bash\nDISPLAY=:0.0 terminator\n```\n\nYou should be able to see the terminator window pops up.\n\nFor WSL 2 the line should be the IP address in `/etc/resolv.conf`.\n\n```bash\nDISPLAY=$(cat /etc/resolv.conf | grep name | cut -d' ' -f2):0.0 terminator\n```\n\n##### Configure Terminator\n\nThe path for terminator configuration file is `~/.config/terminator/config`.\nYou can either create and edit it manually or just right click inside the\nterminator window to set the 'Preferences'.\n\n- I found that smart copy often causes trouble in copying, so I turned it off.\n\n- In 'Profiles'\n\n  - Turn off 'use system font' and choose a powerline font in the\n  list. Choose suitable Font size as you wish.\n\n  - Turn off 'show titlebar' to get rid of the red bar on the top the window.\n\n  - You might want to choose your favorite color scheme or customize one in the\n  'color' tab. I am using a modified one dark color scheme originated from\n  [here](https://github.com/nathanbuchar/atom-one-dark-terminal).\n\n  - You might also want to change the the number of scrollback lines to a much\n  larger value in the 'scroll' tab.\n\n- In 'Keybindings' part, one thing I found that was useful is the 'switch to\ntab' ones. You can bind the them to 'Alt + numbers'\n\nI attached my personal config file in the config folder,\n[terminator_config](config/config), which is generally the same as what I write\nhere.\n\nIf you open another tab with 'shift + ctrl + t' shortcut, you might notice the\ndefault style of the tab is super stupid. This is because terminator uses GTK-3\nand this is the default style of it. To change this, you need customize your\ngtk.css. I followed\n[this link](http://blog.nabam.net/workstation/2017/09/15/terminator_tabs/) to\ncustomize mine. This is how my tabs look like now.\n\n![](images/terminator.png)\n\nYou can find my gtk.css over [here](config/gtk.css) if you like my style. Or\nyou can also DIY it. I didn't know anything about GTK-3 or css, but it just\ntook a few minutes to make the tabs nicer.\n\n##### If You Feel the Text Is Blurry\n\nIf you are using a high DPI monitor, you might find that the text in terminator\nor other applications via X11 blurry.\n\nTo solve this issue, find `vcxsrv.exe` under `C:\\Program Files\\vcxrv` if you\nare using x64 installation or `C:\\Program Files(x86)\\vcxrv` for x86 one and set\nits properties as the image below.\n\n![set vcxsrv properties](images/properties.png)\n\nThis one essentially overrides the DPI scaling in your Windows setting, so you\nmight want to increase the font size in terminator by the scaling factor in\nyour windows setting. Say you were using 14 pt font with 150% scaling, now you\nare going to use 21 pt or so.\n\nHere is a comparison between the default one and after overriding scaling.\n\nDefault                       |  Override\n:----------------------------:|:-----------------------------:\n![def](images/default.png)    |  ![over](images/override.png)\n\n##### Run Terminator from Windows Directly\n\nWith the magic of VB script, we can actually launch terminator directly without\ntouching WSL first. I followed the method in\n[this post](https://blog.ropnop.com/configuring-a-pretty-and-usable-terminal-emulator-for-wsl/)\ninitially.\n\nThe idea is that we can run program with `bash -c` syntax in cmd, ps or bash,\nso we can do this with VB script as well. Since terminator runs over x window,\nin the original post, VcXsrv has to be launched first or added to startup.\n\nHere I borrowed a function to check if VcXsrv is running or not. If not, pop up\na message and launch it. We bothering to do the \"check\" first is because VcXsrv\nwill show an error message if you launch it again when another instance is\nalready running and you have to suppress it manually.\n\nHere is the script.\n\n```VB\nFunction IsProcessRunning(strProcess)\n    Dim Process, strObject\n    IsProcessRunning = False\n    strObject = \"winmgmts://.\"\n    For Each Process in GetObject(strObject).InstancesOf(\"win32_process\")\n    If UCase(Process.name) = UCase(strProcess) Then\n        IsProcessRunning = True\n        Exit Function\n    End If\n    Next\nEnd Function\n\nSet objShell = Wscript.CreateObject(\"Wscript.Shell\")\nIf NOT IsProcessRunning(\"vcxsrv.exe\") Then\n    objShell.Popup \"We will launch vcxsrv.exe first!\", 1, \"VcXSrv is not running\", 64\n    objShell.Exec(\"C:\\Program Files\\VcXsrv\\vcxsrv.exe :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl\")\nEnd If\nargs = \"-c\" \u0026 \" -l \" \u0026 \"\"\"DISPLAY=:0 terminator\"\"\"\nWScript.CreateObject(\"Shell.Application\").ShellExecute \"bash\", args, \"\", \"open\", 0\n```\n\nSave this file as [terminator.vbs](scripts/terminator.vbs). You can simply\ndouble click the .vbs file to launch VcXsrv and terminator together, but to\nfreely choose the icon and the startup path of WSL, we will create a shortcut\nfor this. Here is how.\n\n- Right click somewhere to create a shortcut. Just link to any arbitrary thing,\nas we are going to change it anyway.\n\n- Right click the shortcut we just created and choose 'Properties'. Change the\n'Target' to `C:\\Windows\\System32\\wscript.exe path_to\\terminator.vbs` and 'Start\nin' to `%USERPROFILE%` if you want to make your windows home folder the startup\ndirectory for WSL. (This is something you might want to change this option for\nyou own need.) Then download a nice icon and use it for this shortcut.\n\n![](images/shortcut.png)\n\nYou can find the icon I am using over\n[here](https://raw.githubusercontent.com/tautomer/WSL_Terminator/master/images/terminal.ico).\n\n- Now you can use this shortcut to launch terminator. You can pin this shortcut\nto your start as well.\n\nIn fact you can use this way to launch other GUI programs from your WSL, like\n`evince`. You just have to change 'terminator' to 'evince' in the script.\n\nBy now you will already have a basic setup for WSL and nicer terminal emulator\nthan any windows one I tried.\n\n###### For WSL 2\n\n**Note:** As I wrote in the beginning of the document, for WSL 2, at present,\nchange `DISPLAY=:0` to `DISPLAY=IP:0`, where the IP will be something in your\n`/etc/resolv.conf`.\n\nAlternatively, the smart way will be replace the args in the .vbs script\n\n```VB\nargs = \"-c\" \u0026 \" -l \" \u0026 \"\"\"DISPLAY=:0 terminator\"\"\"\n```\n\nwith\n\n```VB\nargs = \"-c \" \u0026 \"\"\"DISPLAY=$(cat /etc/resolv.conf | grep name | cut -d' ' -f2):0 terminator\"\"\"\n```\n\nThis will automatically take the IP address in the `/etc/resolv.conf` and use\nit to launch terminator.\n\n## Optional Configurations\n\nThere is something we can do to make our Linux environment work better. They\nmay not be useful to you, so I list them in 'optional' part. Here is the list.\n\n- [Run VcXsrv First When Launching Windows Terminal](#run-vcxsrv-first-when-launching-windows-terminal)\n- [Get Correct Unix Permission for NTFS](#get-correct-unix-permission-for-ntfs)\n- [Configure OpenSSH Server on Windows](#configure-openssh-server-on-windows)\n- [Enable X11 Forwarding for SSH](#enable-x11-forwarding-for-ssh)\n- [Share .ssh Folder between Windows and WSL](#share-ssh-folder-between-windows-and-wsl)\n\n### Run VcXsrv First When Launching Windows Terminal\n\nI'm using `Gnuplot` a lot which relies on X display and lazy to launch VcXsrv\nmanually. If you are using the [Terminator way](#use-terminator), VcXsrv is\nalways launched first with the VB script. To do the same thing for the Windows\nTerminal, I have found two ways.\n\n#### Launch VcXsrv inside WSL\n\nThere is no doubt that you can run `vcxsrv.exe` in WSL easily, but unlikely\nrunning it in `cmd`, doing this in WSL will keep your terminal occupied by the\ncommand as the output unless you terminate it.\n\nTo overcome this problem, I'm using Python's `subprocess`.\n\n```python\npython -c 'import subprocess as sp; p=sp.Popen([\"/mnt/c/Program Files/VcXsrv/vcxsrv.exe\", \":0\", \"-ac\", \"-terminate\", \"-lesspointer\", \"-multiwindow\", \"-clipboard\", \"-wgl\", \"-silent-dup-error\"])' 2\u003e/dev/null\n```\n\nYou can use either Python 2 or Python 3, but I think Python is always there, so\nfor safety and compatibility, Python 2 is used here, though I only write Python\n3 codes. `-silent-dup-error` argument will suppress the duplicated display\nerror, so that we don't have to check if VcXsrv is already running or not. (If\nyou really want to do this, `tasklist.exe` is the way to go.) `2\u003e/dev/null`\nwill silent any other messages, so we will have a fresh terminal.\n\nAdd this line to your dot files, like `.profile`, `.bashrc`, `.bash_profile`,\n`.zshrc`, etc. Now you don't have to manually launch VcXsrv any more.\n\n#### With A vbs Script\n\nApparently we can use the same logic used for Terminator to check and launch\nVcXsrv and then launch WSL in the Windows Terminal.\n\nI'm going to change the script a little bit\n\n```VB\nFunction IsProcessRunning(strProcess)\n    Dim Process, strObject\n    IsProcessRunning = False\n    strObject = \"winmgmts://.\"\n    For Each Process in GetObject(strObject).InstancesOf(\"win32_process\")\n    If UCase(Process.name) = UCase(strProcess) Then\n        IsProcessRunning = True\n        Exit Function\n    End If\n    Next\nEnd Function\n\nSet objShell = Wscript.CreateObject(\"Wscript.Shell\")\nIf NOT IsProcessRunning(\"vcxsrv.exe\") Then\n    objShell.Exec(\"C:\\Program Files\\VcXsrv\\vcxsrv.exe :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl\")\nEnd If\n```\n\nIt will only launch VcXsrv if it is not running.\n\nGo back to the `profiles` section in the `profiles.json` file. Change/modify\nthe `commandline` key of WSL to the following\n\n```json\n\"commandline\" : \"wsl.exe -d Debian -- wscript.exe c:/terminal.vbs \u0026 wsl.exe -d Debian\"\n```\n\n`c:/terminal.vbs` is the absolute Windows path of VB script above. `-d`\nspecifies the distro. The first `-d` is not necessary, but the second one has\nto be the one you want to launch. `--` will pass the following argument before\nthe `\u0026` as-is and run it without using the shell, so the first part of this\ncommand will only use WSL to run a Windows command to launch a Windows program\nand the second part will actually launch WSL. I know this one looks completely\ndumb, but this is the only way I found the actually fulfill the job.\n\nAlternatively, you can run the VB script in your dot files, though I haven't\ntested this way myself.\n\n### Get Correct Unix Permission for NTFS\n\nMicrosoft introduce a file called `wsl.conf` to auto configure WSL. We can take\nthe advantage of this file to get rid of the 777 permission problem for the\nfile on NTFS drives.\n\nJust create `/etc/wsl.conf` and add the following contents\n\n```config\n[automount]\nenabled = true\noptions = metadata\n```\n\nsave and then go to services in Windows to restart `lxssmanager` process.\n\nIf this file is faulty, WSL will just ignore it and continue to launch, so you\ndon't have to worry that this file will break your WSL.\n\n### Configure OpenSSH Server on Windows\n\nWhen we enable developer mode, the OpenSSH client is already installed. To\nenable the server, go to `Apps \u003e Additional features \u003e Add a feature` in\nWindows settings and choose `Openssh Server`.\n\nThen go to `Services`, set `Openssh SSH Server` to `Automatic` and manually\nlaunch it for this time.\n![Services](images/services.png)\n\nNow we can already SSH/SCP to our Windows machine directly at port 22 (In\nprinciple you don't have to open this port in your firewall manually.), but to\nmake public key authentication possible, we need do some configurations.\n\nFirst, we need configure `sshd_config` in `%programdata%\\ssh`, i.e.,\n`C:\\programdata\\ssh`. **Note**: you need admin privilege to modify this file.\nUncomment line\n\n```config\nPubkeyAuthentication yes\n```\n\nand comment out lines\n\n```config\n#Match Group administrators\n#       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys\n```\n\nas we want to use the `authorized_keys` file in `%userprofile%\\.ssh` folder.\n\nThen generate SSH keys. Open `cmd` or `PowerShell` window and type\n\n```bash\nssh-keygen.exe -t rsa\n```\n\nto generate keys.\n\n**Next, we need create file `authorized_keys` and set the ACL permission.**\n**This step is very important.** Without correct ACL (not Unix) permission,\npublic keys won't work. Open `Properties` for `authorized_keys` and go to\n`Security` tab click `Advanced`. **Disable 'inheritance'** and **delete all**\n**entries other than 'SYSTEM'**. Add an entries for our own account to have\nread and write permission, so that we can modify the file, but this entry must\nnot have full control over the file. See photo below.\n![permission](images/permission.png)\n\nWith this setup, you will be able to SSH into Windows without password if you\nadd your public keys to `authorized_keys` file.\n\nOne thing to note for SCP to Windows is that the path should be\n`windows_user@host:disk:/path`, e.g., `doe@localhost:c/Users`.\n\n### Enable X11 Forwarding for SSH\n\nPersonally, I need visualize some data or figures on the remote host, so X11\nforwarding is very important to me. However, enabling this option in WSL is\nkind of ambiguous. I struggled several times and checked multiple sources, but\nI'm not sure which step is necessary. Nevertheless, this way indeed works.\n\nFirst of all, install OpenSSH server for WSL\n\n```bash\nsudo apt install ssh\n```\n\nand then modify `/etc/ssh/sshd_config` file like this block below, by either\nuncommenting or adding.\n\n```config\nPort 2222\nAddressFamily inet\nListenAddress 0.0.0.0\nPermitRootLogin no\nAllowUsers your_user_id\nPubkeyAuthentication yes\nPasswordAuthentication yes\nX11Forwarding yes\nX11UseLocalhost no\n```\n\nNote that since I enabled OpenSSH server for windows, too and would like to\nkeep default 22 port for it, the one for WSL is changed to 2222.\n\nThen run command\n\n```bash\nxauth add :0 . `mcookie`\n```\n\nto obtain correct authentication.\n\nWith this setup, you should be able to get your GUI stuff forwarded to you\nlocal terminal.\n\n### Share .ssh Folder between Windows and WSL\n\nNow you have two SSH server running, one in Windows and one in WSL, so you\nmight think of sharing the public key and authorized keys between them. It is\nindeed possible, but maybe keeping two sets of .ssh folders is better.\n\nYou can find the reference\n[here](https://florianbrinkmann.com/en/3436/ssh-key-and-the-windows-subsystem-for-linux/).\n\nFirst of all, make sure you enabled `metadata` for NTFS stuff like\n[this](###Get-Correct-Unix-Permission-for-NTFS), so that we can get the Unix\nstyle permission persistent for Windows files.\n\nThen create a symbolic link between the .ssh folder in your `%userprofile%` and\nyour WSL `$HOME`.\n\n```bash\nln -s /mnt/c/Users/windows_user/.ssh ~/.ssh\n```\n\nSet correct permission for files after that. They are like the following.\n\n```bash\n-rw-r--r-- 1 user user 1.6K Apr  9 13:22 authorized_keys\n-rw------- 1 user user 1.7K Apr  9 09:58 id_rsa\n-rw-r--r-- 1 user user  394 Apr  9 09:58 id_rsa.pub\n-rw------- 1 user user  11K May  5 00:14 known_hosts\n-rw------- 1 user user 1.4K Apr 18  2017 known_hosts.old\n```\n\nFinally, disable strict modes in your `sshd_config`. **Warning: this isn't a**\n**good practice, but I can't make it work without this.**\n\n```config\nStrictModes no\n```\n\nSo now you can keep one copy of `id_rsa.pub` and `authorized_keys` for both\nWindows and your WSL.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftautomer%2FWSL_Windows_Terminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftautomer%2FWSL_Windows_Terminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftautomer%2FWSL_Windows_Terminal/lists"}