• Requires Token2Shell version 15.1.0 or higher
  • Windows 10 April 2018 Update (1803) and
    Ubuntu 18.04 were used while preparing this post

STEP 1 Install OpenSSH server

We'll be using Ubuntu 18.04 and OpenSSH server for this example. If you're using a different Linux distribution, please consult its manual for installing an SSH server. You don't have to use an OpenSSH server; if you prefer a different sever, just make sure it's properly supported in WSL.

For more information about installing an OpenSSH server on Ubuntu 18.04, please visit:

While configuring your SSH server, please make sure the "password" user authentication is enabled; we'll be using the 'password' user authentication for automatically logging into WSL.

STEP 2 Set the "password" as your first preference for the default SSH user auth. methods

Please note that you don't have to select the "Enable X11 Forwarding" option in order to use X Window apps on WSL. Even though you're connecting to WSL via SSH, you're still in the same local computer as WSL; you can directly connect to the X server. In order to use X Window apps, just make sure your DISPLAY environment variable is correctly pointing to the X server. For example, if you're using X410, your DISPLAY environment variable should be set to

export DISPLAY=

Click the Back button and return to the desktop.

STEP 3 Test starting an SSH session from Command Prompt

Open Command Prompt and try connecting to WSL and see if you can login without any password. You should use the following format for starting a session:

start ssh://<your-wsl-username>:<your-wsl-password>@

Please change the "<your-wsl-username>" and "<your-wsl-password>" to your user name and password for WSL. For example, if your user name is 'luca' and the password is '123456', the command line should be:

start ssh://luca:123456@

If your SSH server is not using the default SSH port number (22), you need to append the number at the end with a colon (:). For example, if your server is at 2222, your command line should be:

start ssh://luca:123456@

STEP 4 Create a folder for WSL related scripts and assets

It can be any folder on any drive, but for the sake of simplicity, let's create it on C: drive and name it 'wsl': c:\wsl. If you've decided to use a different folder path, please make adjustments accordingly to the scripts and registry settings described in the next steps.

We're using a VBScript and a Windows batch file (open-token2shell-here.bat) to launch Token2Shell. You can directly launch Token2Shell without those files. However, we're using them in order to simplify managing the commands (instead of editing the Windows registry, you can just edit the files) and to hide the Command Prompt window that pops up whenever Windows commands are executed.

STEP 5 Create a VBScript file for executing a batch file without any flashing Console window

We can directly execute the batch file that will be created in Step 5 for actually launching Token2Shell. However, Windows always shows a Command Prompt window when executing a batch file; we couldn't find a way to completely hide it. By using this VBScript, we can silently run the batch file and open Token2Shell.

If WScript.Arguments.Count <= 0 Then
End If	

bat = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\")) & WScript.Arguments(0) & ".bat"
arg = ""

If WScript.Arguments.Count > 1 Then
    arg = WScript.Arguments(1)
End If

CreateObject("WScript.Shell").Run """" & bat & """ """ & arg & """", 0, False

Please note that the above VBScript automatically attaches the ".bat" file extension to its first argument and executes it as if it's a batch file in the same folder.

STEP 6 Create a Windows batch file (*.bat) for launching Token2Shell

ubuntu1804.exe run "echo '<your-wsl-password>' | sudo -S service ssh start"
start ssh://<your-wsl-username>:<your-wsl-password>@$(wslpath%%20'%1');clear;$SHELL%%20--login

Please change the "<your-wsl-username>" and "<your-wsl-password>" to your user name and password for WSL. If your SSH server doesn't use the default SSH port number (22), you need to adjust the command line as mentioned in Step 3. For example, if your SSH server is at port 2222 and your user name and password for WSL are 'luca' and '123456' respectively, your batch file should be:

ubuntu1804.exe run "echo '123456' | sudo -S service ssh start"
start ssh://luca:123456@$(wslpath%%20'%1');clear;$SHELL%%20--login

WSL currently doesn't support automatically launching server programs (or daemons). Hence our OpenSSH server must be started manually but the current version of WSL now does allow having servers running in background even when all Linux terminal windows are closed. All in all, instead of immediately starting the OpenSSH server when you login to Windows, our batch file launches the server just before it's actually needed for Token2Shell.

In order to start an OpenSSH server, you need to use the 'sudo' command in Ubuntu. In our batch file, we're using the 'echo' command with 'sudo -S' in order to feed your password to the 'sudo' command. If you're using the same password as Windows login, we highly recommend changing it. WSL manages its own separate accounts from Windows, so you should set a different password (perhaps a simpler one) only for WSL.

There are other ways to start the server. But as far as we know they all focus on permanently removing the password for the 'sudo' command and require editing a system configuration file on Linux (ex. editing the '/etc/sudoers' file with 'visudo' command). Our approach of using the 'sudo -S' is much simpler and should provide more flexibility since it can also be used for other servers without changing any system file on Linux.

STEP 7 Create a registry file for setting up the right-click menu

Windows Registry Editor Version 5.00




@="Open Token2Shell here"

@="wscript.exe \"C:\\wsl\\bat-launcher.vbs\" \"open-token2shell-here\" \"%V\""


@="Open Token2Shell here"

@="wscript.exe \"C:\\wsl\\bat-launcher.vbs\" \"open-token2shell-here\" \"%V\""

If you're not using "c:\wsl" for the scripts created in Step 5 and 6, please make sure to adjust the paths for 'open-token2shell-here.vbs' and 'open-token2shell-here.bat' according to your setup.

Once you have the 'set-open-token2shell-here-menu.reg' file, you can import it to Windows registry by double-clicking it or using the 'Import' menu from the Windows 'regedit' program.