
The author’s main working environment has always been Linux, but in some scenarios, it is still impossible to bypass the Windows system. Therefore, the author has a Windows notebook that is always on standby at home. When the author has a need, he will connect back to the VPN network at home to use this terminal. At this time, the problem arises. Because the author is extremely familiar with the Linux command line environment and the command line tools under Windows are relatively scarce, is there a way to comfortably use Windows to work in the command line scenario? The answer is yes, let me explain.
Install WSL
Install WSL using PowerShell, execute Reference 1 in PowerShell with administrator privileges Reference 1:
- wsl --install
After the installation is complete, WSL will generate the bash.exe we need under System32:

Install OpenSSH server
Currently, the Windows platform natively supports the OpenSSH server and no longer requires additional third-party software packages. It can be installed through PowerShell Reference 2, and the following command can be executed with administrator privileges. Remember to set the service to start automatically.
- Windows PowerShell
- Copyright (C) Microsoft Corporation。All rights reserved。
- Try the new cross-platform PowerShell https://aka.ms/pscore6
- PS C:\Windows\system32> Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
- Name : OpenSSH.Client~~~~0.0.1.0
- State : Installed
- Name : OpenSSH.Server~~~~0.0.1.0
- State : NotPresent
- PS C:\Windows\system32> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
- Path :
- Online : True
- RestartNeeded : False
- PS C:\Windows\system32> Set-Service -Name sshd -StartupType 'Automatic'
- PS C:\Windows\system32> Start-Service sshd
Finally, set the default command line of OpenSSH Server to WSL’s bash.exe and restart the SSH service.
- PS C:\Windows\system32> New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\bash.exe" -PropertyType String -Force
- DefaultShell : C:\Windows\System32\bash.exe
- PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH
- PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE
- PSChildName : OpenSSH
- PSDrive : HKLM
- PSProvider : Microsoft.PowerShell.Core\Registry
- PS C:\Windows\system32> ReStart-Service sshd
Finally, it’s OK to use the main notebook to connect to this machine.

Last thing
The Ubuntu that comes with WSL seems to have some problems. There is a certain probability that it will get stuck when starting bash.exe. I am using a third-party created Arch distribution, which can be obtained at the following address:https://github.com/yuk7/ArchWSL
If you want a colored Prompt, you need to set PS1 through .bashrc. The configuration of WSL is a bit more troublesome and requires the configuration of the following two files:
- [root@VPNBook ~]# cat ~/.bash_profile
- source ~/.bashrc
- [root@VPNBook ~]# cat ~/.bashrc
- export PS1="\[\e[01;37m\]┏╸\[\e[00;37m\]\u\[\e[01;37m\]@\[\e[01;36m\]\h \[\e[01;35m\]\t \[\e[38;5;214m\]\w\n\[\e[01;37m\]┗╸\[\e[01;32m\]\\$ \[\e[00m\]"
- alias ll="ls -l --time-style=long-iso --color"