No WSL After 2 Day

AB2
6 min readAug 21, 2023

--

No WSL After 2 Day ! OR No Windows System Linux After Today !

This document explains how to install a virtual Linux system on your Windows machine without relying on WSL.

Final result

Download

Below are the software and application names mentioned in this document:

Windows Terminal Preview

VirtualBox

Kali Linux

Setting our virual machine using VirtualBox

After downloading and installing Windows Terminal and VirtualBox, the next step is to extract the Kali Linux OVA Image file and import it into VirtualBox. It is not necessary to modify any settings at this stage; simply leave everything as the default settings.

Once the image has been successfully imported, proceed to modify some machine settings by right-clicking on the machine, selecting ‘Settings,’ and following the steps shown in the accompanying screenshots below

1) In the advanced tab let’s choose Bidirectional for both of Shared Clipboard & Drag'nDrop

2) We recommend allocating 2 CPUs and 2 GB of RAM for the system’s base memory and processor.

3) For the network, select ‘NAT,’ as this is a required configuration.

4) Share a folder from your windows to the linux machine, In my case I shared my WIN desktop and mounted to /root/Desktop/Windows/. Be sure to select the Make Permanent option to ensure the folder remains accessible.

After that you set everything click OK and Ð congrats! Your machine is ready.

Great ! Now let’s run our virtual machine in normal mode …

Default creds: kali/kali

We need this to check only if our VM is working fine and also to check the network settings.

Now generate a new ssh key for any user, I always like to be root.

So by going to terminal and type sudo su - then ssh-keygen and pressing Enter few times to generate the key, this will automatically save both the private and public keys in /root/.ssh/id_rsa

After that let’s copy id_rsa.pub to authorized_keys by typing: cp id_rsa.pub authorized_keys, then changing the file permissions using chmod to set the access mode to 600 chmod 600 authorized_keys.

And then copy the private key cat /root/.ssh/id_rsa

And paste it into your Windows Desktop Directory

It’s important to also change the permissions of the id_rsa file in Windows.

Please save the code in a file with a .cmd or .bat extension, and then execute it.

@echo Changing id_rsa Permission
icacls .\id_rsa /inheritance:r
icacls .\id_rsa /grant:r "%username%":"(R)"
@pause

Awesome! Now let’s add this line to our C:\Windows\System32\drivers\etc\hosts file

127.0.0.1 kali.box

Return to VirtualBox and access the settings for the Kali machine. Navigate to the ‘Network’ category and click on ‘Advanced’

Next, select ‘Port Forwarding’

And follow the steps in this screenshot -

This rule enables direct connection from the Windows machine to the SSH port of the Kali VM.

Return to the machine and modify the sshd_config file to allow root logins nano /etc/ssh/sshd_config

Let’s change this line to

PermitRootLogin yes

After modifying the sshd_config file, restart the SSH service and enable it if it was not enabled by default.

Commands:

# To restart SSH
systemctl restart ssh
# To enable SSH
systemctl enable ssh

Setting our Windows Terminal

Now after that everything is set in our Kali virtual machine … Let’s go to the Windows Terminal and create a new profile

Now follow the steps shown in the screenshot below

The command line:

ssh.exe -i id_rsa root@kali.box

Note: Starting directory must be where we have our SSH id_rsa private key.

After you set everything as shown click ‘Save’ and then go to startup and choose your new profile as the Default profile . Don’t forget to click on ‘Save’.

After restarting the Windows Terminal, it will automatically run the SSH command and connect you to your Kali VM.

type yes and click Enter

To open the shell directly on our shared Desktop, we can add in the end of the file ~/.zshrc the mounted point (path) we set earlier

cd /root/Desktop/Windows
# or
cd ~/Desktop/Windows

Make it run at startup and headless

Go to C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup, replace the value ‘Username’ with your computer username and create a new file. Let’s name it kali_vbox.bat

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "Kali-Linux-2021.4-vbox-amd64" --type headless

First check if VBoxManage.exe is in the right path and the "Kali-Linux-2021.4-vbox-amd64" value we can get from the box Name in the settings.

Congratulations! The Linux VM will now run in the background and you can use everything on your Windows desktop as if you were working on Linux.

Additional Port Forwarding in my own configuration

The first IP is the IP address of my THM VPN, which I connect to using my Windows machine. I use this rule when playing a machine in THM or HTB, but I need to update the IP each time if I am not using a VIP membership.

The 2nd IP 10.0.2.15 is the default IP address for the NAT network adapter.

Thanks

Finally, I would like to thank leeloo1313 for the encouragement and help in writing this setup guide.

If you liked this content and want to encourage me for more, you can buymeacoffee.

Original blog post: http://ab2pentest.vip/2021/12/14/No-Wsl-After-2Day.html

--

--

AB2

Security Engineer @ TS | Ethical Hacker | Content Creator | CTF Player.