250x250
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- mysql
- QGIS
- insert into
- hadoop #hdfs
- uuid
- Kafka
- JPA
- 1093
- spring
- AuthenticationPrincipal
- posgis
- Geoserver
- LazyInitializationException
- nginx
- Java
- Failed to load ApplicationContext
- RDB
- sftp
- Maven
- #mojo
- postgres
- psycopg2
- postgresql
- python
- spring boot
- JSON Web Token
- Linux
- Spring Security
- Docker
- JWT
Archives
- Today
- Total
FOREST_CHOI's BLOG
Mac에서 Window WSL 접속하기 본문
728x90
일단 wsl에서 openssh-server를 재설치 해줘야한다.
sudo apt remove openssh-server
sudo apt update -y && sudo apt upgrade -y
sudo pat install openssh-server
그다음 sshd_config 파일을 수정해주어야한다.(Sudo로 들어가서 수정해 주어야한다.)
sudo vi /etc/ssh/sshd_config
Port 22
PasswordAuthentication yes
위 두가지 줄을 주석 해제한다.
이후 ssh 서버를 재시작한다.
sudo service ssh --full-restart
다음 윈도우에서
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$remoteport = bash.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 {
Write-Output "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
$ports = @(3000, 3001, 5000, 5500, 19000, 19002, 19006, 22);
Invoke-Expression "netsh interface portproxy reset";
for ( $i = 0; $i -lt $ports.length; $i++ ) {
$port = $ports[$i];
Invoke-Expression "netsh interface portproxy add v4tov4 listenport=$port connectport=$port connectaddress=$remoteport";
}
Invoke-Expression "netsh interface portproxy show v4tov4";
위에 스크립트를 ps1 이라는 확장자로 저장한 후 실행한다.
ex) port_wsl.ps1 -> .\port_wsl.ps1
--> 실행이 안될떄가 있는데 이떄 Set-ExecutionPolicy RemoteSigned 를 수행하오 모두 예를 선택해준다.
그리고 맥에서
ssh { wsl id } @ { wsl ip } -p {port}
를 실행하면 접속이 된다.
** 원도우를 껐다켜면 ssh를 수동으로 실행해줘야하는것 같다. -> 자동화할수있을듯?
728x90
'운영 > Linux' 카테고리의 다른 글
| Nginx 파일 다운로드 서버 구축하기 - SIMPLE (0) | 2023.01.31 |
|---|---|
| SFTP - 파일 업로드 및 다운로드 (For Mac) (0) | 2023.01.31 |
Comments