Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

Static IP WSL2

netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=22 connectaddress=172.19.237.178 connectport=22
Comment

Static IP WSL2

#The IP address of a WSL2 machine cannot be made static, however it can be determined using
	wsl hostname -I
#Based on this, Create the following powershell script that will start sshd on the WSL machine
#and route traffic to it.
	wsl.exe sudo /etc/init.d/ssh start
	$wsl_ip = (wsl hostname -I).trim()
	Write-Host "WSL Machine IP: ""$wsl_ip"""
	netsh interface portproxy add v4tov4 listenport=22 connectport=22 connectaddress=$wsl_ip

#Add the following line to the sudoers file via visudo to avoid needing a password to start sshd	
    %sudo ALL=(ALL) NOPASSWD: /etc/init.d/ssh

#From a powershell terminal, Scheduled the script to run at startup
	$trigger = New-JobTrigger -AtStartup -RandomDelay 00:00:15
	Register-ScheduledJob -Trigger $trigger -FilePath C:
oute_ssh_to_wsl.ps1 -Name RouteSSHtoWSL
Comment

PREVIOUS NEXT
Code Example
Shell :: filezilla Directory /var/lib/docker: permission denied 
Shell :: how to uninstall cuda 
Shell :: remove write proteced in usb ubuntu 
Shell :: install kubectl windows 
Shell :: how to install source plugin gatsby 
Shell :: how to install powershell 
Shell :: jenkins execute shell script on remote host using ssh 
Shell :: awk delimiter comma 
Shell :: npm i postgresql 
Shell :: .bat script on computer startup 
Shell :: get public ip 
Shell :: make zip file command 
Shell :: install grub manually 
Shell :: Fetch submodules recursively 
Shell :: scp folder copy 
Shell :: ssh permissions are too open 
Shell :: install open jdk 8 mac homebrew 
Shell :: install vim in vs 
Shell :: terminal show running processes tree mac os 
Shell :: uname linux 
Shell :: How to create and extract an archive or .tar file using linux commands 
Shell :: export docker image 
Shell :: vim plug not working 
Shell :: install gitflow 
Shell :: git clone does not show all branches 
Shell :: ssh option to send null packets 
Shell :: permanent noh vim 
Shell :: restart nginx windows 
Shell :: install h5py ubuntu 20.04 pip 
Shell :: user friendly linux distro 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =