sudo apt remove openssh-server
sudo apt update
sudo apt install openssh-server
sudo vi /etc/ssh/sshd_config
Port 22 # 주석처리 되어 있으면 주석 해제, 기본 SSH Port 번호는 22, 보안을 위해서 다른 번호로 변경 추천
PasswordAuthentication no를
PasswordAuthentication yes로 변경
sudo service ssh --full-restart
sudo visudo
# 열린 파일 가장 아래에 구문 추가하고 저장
%sudo ALL=NOPASSWD: /usr/sbin/service
@echo off
"C:\Users\SHIN\AppData\Local\Microsoft\WindowsApps\ubuntu2204.exe" -c "sudo service ssh start"
$remoteport = ubuntu2204.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
#[Ports]
#All the ports you want to forward separated by coma
$ports=@(80,443,5000,22);
#[Static ip]
#You can change the addr to your ip config to listen to a specific address
$addr='0.0.0.0';
$ports_a = $ports -join ",";
#Remove Firewall Exception Rules
iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' ";
#adding Exception Rules for inbound and outbound Rules
iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol TCP";
iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol TCP";
for( $i = 0; $i -lt $ports.length; $i++ ){
$port = $ports[$i];
iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr";
iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport";
}
Invoke-Expression "netsh interface portproxy show v4tov4";
# from
$ports=@(80,443,5000,22);
# to
$ports=@(80,443,5000,23456);
https://jackcokebb.tistory.com/18
https://jackcokebb.tistory.com/18
https://jackcokebb.tistory.com/18
MesloLGS NF
** 윈도우 부팅 시 4.가 자동으로 작동되지 않음, 왜 그럴까?