DEV Community

Discussion on: 🌟Install Jenkins in Windows Subsystem for Linux (WSL2)

Collapse
 
francisvila profile image
Francis Vila

Everything works up to sudo ufw enable .
This triggers an error starting with

ERROR: problem running ufw-init
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.0-19041-Microsoft/modules.dep.bin'
Enter fullscreen mode Exit fullscreen mode

Looking up the errors does not give encouraging results. It appears ufw does not function with WSL.
This link: askubuntu.com/questions/1100739/i-... even concludes (about ufw on WSL) that "Some tools are really not portable to different platforms".

I read a stackoverflow post (stackoverflow.com/questions/660185... ) saying "Just let the Windows Firewall do its job if you are concerned about external access to the Nginx. " But no clues as to how to do this.

I'm using Ubuntu 18.04

Collapse
 
alogan5201 profile image
alogan5201

I had the same issue and this resolved it:
Run:
sudo nano /usr/lib/python3/dist-packages/ufw/util.py

Replace under_ssh function with

def under_ssh(pid=None):
'''Try to determine if we are being run from an ssh session'''
if pid is None:
pid = str(os.getpid())

ppid = None
try:
    name = "/proc/%s/stat" % pid
    ppid = open(name).readlines()[0].split(')')[1].split()[1]
except IOError:
    err_msg = _("Couldn't find parent pid for '%s'") % pid
    raise ValueError(err_msg)
except IndexError: # Add this block
    return False

if ppid == '1':
    return False

name = "/proc/%s/cmdline" % ppid
try:
    cmdline = open(name).readline().strip().split('\x00')
except IOError:
    return False

for i in cmdline:
    if re.search('sshd', i):
        return True

return under_ssh(ppid)
Enter fullscreen mode Exit fullscreen mode