ssh into WSL2 & vs-code
ssh into WSL2 & vs-code
์์ฑ์ผ: 2022๋ 3์ 2์ผ ์คํ 11:30
๋ช ๊ฐ์ง ๋ฐฉ๋ฒ์ด ์๋ค. ํ๋๋ Windows ์์ฒด์ sshd ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ๊ณผ WSL ๋ด๋ถ์ sshd ๋ฐ๋ชฌ์ผ๋ก ํฐ๋๋ง ํ๋ ๋ฐฉ๋ฒ์ด์๋ค.
Windows ์์ฒด์ sshd๋ฅผ ์ฌ์ฉํด๋ณด์
PC-A์์ PC-B์ ์๋์ฐ๋ก ssh๋ฅผ ํ ์ ์๋ ๋ช ๋ น์ด๋ ๋ค์๊ณผ ๊ฐ๋ค
# Powershell as Administrator
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Set-Service -Name sshd -StartupType 'Automatic'
์ด์ ์ธ๋ถ์์ ํด๋น ์๋์ฐ(PC-B)๋ก ssh๋ฅผ ์ฐ๊ฒฐํด ๋ค์ด๊ฐ๋ฉด ํ์์ ํ๋กฌํํธ๋ฅผ ๋ง๋ ์ ์๋ค.
๊ธฐ๋ณธ ์ ธ์ ํ์์๋ก ๋ณ๊ฒฝ
https://www.lainyzine.com/ko/article/how-to-run-openssh-server-and-connect-with-ssh-on-windows-10/
์๋๋ powershell 7 ๊ธฐ์ค ๋ช ๋ น์ด์ธ๋ฐ, ๋ค๋ฅธ ๋ฒ์ ์ ์ฌ์ฉํ๊ณ ์ถ๋ค๋ฉด ๋ค์ MS ๋ฌธ์ ๋ฅผ ํ์ธํด์ DefaultShell -Value ๊ฐ์ ์์ ํ์ธ์
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "$env:ProgramFiles\Powershell\7" -PropertyType String -Force
WSL๋ก ์๋์ ์ฅ์ด ๋๊ฒ ๋ง๋ค์ด๋ณด์
์๋ ์ปค๋งจ๋๋ ssh ์ ์ฅ์ ์ฌ์ฉํ ๊ธฐ๋ณธ์ ธ์ ์ค์ ํ ์ ์๋ค. bash.exe ํ์ผ๋ก ์ค์ ํด ๋์๊ณ , ์ด๋ ์๋์ฐ๊ฐ ์์์ ์ผ๋ก wsl์ ํธ์ถํ๊ธฐ ๋๋ฌธ์ ssh๋ฅผ ํตํด WSL ๋ฐฐ์ ์ ธ๋ก ๋ค์ด๊ฐ๊ฒ ๋๋ค.
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\WINDOWS\System32\bash.exe" -PropertyType String -Force
ํ์ง๋ง ๋๋ ์์ฌ์ ๋ด์ด ํ์์ ธ๊น์ง ์ฌ์ฉํ๊ณ ์ถ์๋ค. shutdown๋ ํ ์ ์๊ฒ ๋ง์ด๋ค! ๊ทธ๋์ ํด๋น ํ๋กํผํฐ๋ฅผ ๋ค์ ์ญ์ ํ๋ค.
Remove-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" - Name DefaultShell
Problem shooting: WSL์ Microsoft Store ์ถ์์ ๊ดํ ๋ฌธ์
Cannot run WSL2 over SSH on Windows 11
MS Store์ WSL์ด ์ฌ๋ผ์๊ธฐ์ ๋๋ ํ์ฌ๋ฆผ์ ํ ์ ์ด ์๋ค. ๊ทธ ๋ค๋ก ssh ์ฐ๊ฒฐ์ wsl๋ก ํ ์๊ฐ ์์๋๋ฐ, ์์ง ํด๊ฒฐ๋์ง ๋ชปํ ์ด์์๋ค๊ณ ํ๋ค. ๋ฐ๋ผ์ MS Store์ ์ค์น๋์ด์๋ WSL์ ์ง์ฐ์ ์ฐ๊ฒฐ์ด ๊ฐ๋ฅํด์ก๋ค.
VS Code์ ssh๋ก ์๊ฒฉ์ ์ํ๊ธฐ
Developing on Remote Machines using SSH and Visual Studio Code
ํ๋ผ๋ ๋๋ก ํ๋๋ฐ๋ ์ ๋๋ค. ๊ทธ๋์ ์ฌ์ง์ด vs-code๋ ์ญ์ ํ๊ณ vs-code-server๋ ์ ๋ถ ์ญ์ ํด๋ดค๊ณ ์ปดํจํฐ๋ ๋ค์์์ ํ๋๋ฐ๋ ๋ถ๊ตฌํ๊ณ ์ฐ๊ฒฐ์ด ์ ๋์๋ค.
Vscode cannot connect to remote Linux ๏ผ_WebSocket close with status code 1006๏ผ
๊ทธ๋ฐ๋ฐ ์ด์ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์ง๋ง wsl --shutdown
์ ์ฌ์ฉํด ๋ฆฌ๋
์ค๋ฅผ ์ข
๋ฃ์ํจ ๋ค์ ๋ค์ ์ผ๋๊น ๋๋ค. ๋ญ์ง
Vs Code์ Remote Tunnel๋ก ์๊ฒฉ ์ ์ํ๊ธฐ
ssh ์ฐ๊ฒฐ ์์ด ๊นํ๋ธ ๊ณ์ ๋ง์ผ๋ก ์๊ฒฉ vs-code ์๋ฒ๋ฅผ ์ฌ์ฉํ ์ ์๋ ๊ฐ์ฉ๋ ๊ธฐ๋ฅ์ด ์ธ์ ๋ชจ๋ฅด๊ฒ ์ถ์ํ๋ค. ์น์ผ๋ก๋ ์ฐ๊ฒฐ์ด ๊ฐ๋ฅํด ์์ดํจ๋๋ก๋ ์ฝ๊ฒ ๋ฐ์คํฌํฑ ์์์ ์ฌ์ฉํ ์ ์๋ค.
์ฌ์ฉํด๋ดค์ผ๋ ์น๋ช ์ ์ธ ๋จ์ ์ด ์กด์ฌํ๋ค.
-
์๊ฒฉ์ผ๋ก ์ปดํจํฐ๋ฅผ ์ผฐ์ ๋ vs-code๊ฐ ์คํ์ด ๋ ์ํ๊ฐ ์๋๋ฏ๋ก ๋ฆฌ๋ชจํธ ํฐ๋๋ง์ด ์๋๋ค. โ ๋ฌผ๋ก RDP๋ก ๋ค์ด๊ฐ ์์๋ก ์คํ์์ผ์ฃผ๋ฉด ๊ฐ๋ฅํ๊ธฐ๋ ํ์ง๋งโฆ ๋๋ฌด ๋ฒ์ก์ค๋ฝ์์.
2023-03-13T17:53:04 ์์ :
code tunnel service install
ํ๋ฉด ๋๋ค. ์์ผ๋ก ์ปดํจํฐ๋ฅผ ์๊ฒฉ์ผ๋ก ์ผ๊ธฐ๋ง ํ๋ฉด ssh ์ฐ๊ฒฐ ์์ด ๋ฐ๋ก ์๊ฒฉ์ ์์ด ๊ฐ๋ฅํ๋ค.
[์์ ] ssh๋ก ์ฐ๊ฒฐ๋ ์ํ์์ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์น๋ฉด remote tunnel์ ์ด์ด์ค๋ค!
code tunnel
*
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*
To grant access to the server, please log into https://github.com/login/device and use code AAAA-AAAA
์น์ ํ ์ค๋ช
์๋๋ก ํด๋น ๋งํฌ๋ก ๋ค์ด๊ฐ ๋ก๊ทธ์ธ์ ํ๊ฒ ๋๋ฉด cli ์์์ ๋งํฌ๋ฅผ ํ๋ ๋ ์ค๋ค. ๊ทธ ๋งํฌ๋ฅผ ํ๊ณ ๋ค์ด๊ฐ๋ฉด ๋ณธ๊ฒฉ์ ์ผ๋ก ์น์์ vs-code๋ฅผ ์ฌ์ฉํ ์ ์๊ฒ ๋๋ค.
ํ ๋ฒ ํฐ๋์ ์คํํ ์ํ์์ ๋๋ ์ด๋ ์น ๋ธ๋ผ์ฐ์ ๋ก ๋ค์ด๊ฐ๋ vscode.dev ์ฌ์ดํธ๋ฅผ ๋ค์ด๊ฐ ๊นํ๋ธ๋ก ๋ก๊ทธ์ธ ํ๊ธฐ๋ง ํ๋ฉด ์ธ์ ๋ ์ง ์๊ฒฉ ์ ์์ ํ ์ ์๋ค. ๊ฐ์ฉ๋ค.
WSL2๋ฅผ ์ธ๋ถ SSH์ ์ฐ๊ฒฐํ๊ธฐ ์ํ ํฌํธํฌ์๋ฉ ์๋ํ Powershell script (scrap)
WSLv2๋ฅผ ์ธ๋ถ SSH ์ฐ๊ฒฐํ๊ธฐ ์ํ ํฌํธํฌ์๋ฉ ์๋ํ Powershell script
Windows์ ssh key ์ถ๊ฐํ๊ธฐ
$env:ProgramData
๋๋ %ProgramData%
ํ๊ฒฝ๋ณ์ ์์ ์๋ ssh\administrators_authorized_keys
ํ์ผ์ ํผ๋ธ๋ฆญ ํค์ ๋ด์ฉ์ ์ถ๊ฐํ์ฌ์ผ ํ๋ค. $env:Home\ssh\authorized_keys
๋ฅผ ์์ ํ๋ค๊ณ ์ ์ฉ์ด ๋์ง ์์ ๊ณ ์ํ๋ค.
๊ทธ๋ฆฌ๊ณ ํค๋ฅผ ์ถ๊ฐํ ๋ค๋ก๋ ๊ผญ Restart-Service sshd
๋ฅผ ์ฌ์ฉํ์ฌ ๋ฐ๋ชฌ์ ์ฌ์์ ํด์ฃผ์ด์ผ ํ๋ค.
wsl์์ update.code.visualstudio.com
์ ์ ๊ทผํ ์ ์๋ค๋๋ฐ?
์๋ฌ๋ฉ์์ง๋ฅผ ์์ฝํ์๋ฉด...
๋ ์ง๊ธ update.code.visualstudio.com์ ์ ๊ทผํ ๊ถํ์ด ์์ผ๋๊น vscode-server-linux-x64.tar.gz ํ์ผ์ ๋ค์ด๋ฐ์ ์ ์์ด
code
Updating VS Code Server to version 6445d93c81ebe42c4cbd7a60712e0b17d9463e97
Removing previous installation...
Installing VS Code Server for x64 (6445d93c81ebe42c4cbd7a60712e0b17d9463e97)
Downloading: 100%
Failed
--2023-08-21 10:53:55-- https://update.code.visualstudio.com/commit:6445d93c81ebe42c4cbd7a60712e0b17d9463e97/server-linux-x64/stable
Resolving update.code.visualstudio.com (update.code.visualstudio.com)... 13.107.246.74, 13.107.213.74, 2620:1ec:bdf::74, ...
Connecting to update.code.visualstudio.com (update.code.visualstudio.com)|13.107.246.74|:443... connected.
ERROR: cannot verify update.code.visualstudio.com's certificate, issued by โCN=Microsoft Azure TLS Issuing CA 05,O=Microsoft Corporation,C=USโ:
Unable to locally verify the issuer's authority.
To connect to update.code.visualstudio.com insecurely, use `--no-check-certificate'.
ERROR: Failed to download https://update.code.visualstudio.com/commit:6445d93c81ebe42c4cbd7a60712e0b17d9463e97/server-linux-x64/stable to /home/chltm/.vscode-server/bin/6445d93c81ebe42c4cbd7a60712e0b17d9463e97-1692582835.tar.gz
Please install missing certificates.
Debian/Ubuntu: sudo apt-get install ca-certificates
ํด๊ฒฐ!!!!! ๋ฟ์์
!!! ์๋ ๋ํ์ ๋ต๋ณ์์ ํด๋ต์ด ์๋ค. ๊ฒฐ๊ตญ์ ํ์ผ์ ์ง์ ๋ค์ด๋ฐ์ ์ ์์ผ๋๊น ์ฐ๋ฆฌ๊ฐ ์ง์ ๊ฝ์๋ฃ์ด์ฃผ๋ฉด ๋๋ ๊ฒ์ด์๋ค. ์ด๋ ์ค์ํ ๊ฑด $COMMIT_ID
๋ฅผ ์ฐพ๋ ๋ฐฉ๋ฒํ๊ณ ๋ค์ด๋ฐ์ ํ์ผ์ ์์ถํด์ ํ ๋ค์ --strip-components 1
์ต์
์ ์ฃผ์ด ๋ฐ๋ก ๊ทธ ํด๋์ ๋ด์์ผ ํ์ง ์๋ฌด ์ต์
๋ ์ฃผ์ง ์์ผ๋ฉด ํด๋๋ฅผ ์์ฑํ์ฌ ๊ทธ ์์ ๋ด์์ฃผ๋ฏ๋ก ๋์ ์ฐจ์ด ๊ทธ๊ฑฐ ๋ช
์ฌํ์.
remote ssh in vscode on a target machine that only allows inbound ssh connections {sof}
๋ฌผ๋ก ์ธ์ ๊ฐ ์ ca-certificates
๊ด๋ จ ๋ฌธ์ ๊ฐ ๋ค์ ์ฐพ์์ฌ ๊ฒ์ด๊ณ , vscode-server ์
๋ฐ์ดํธ๊ฐ ๋งํ ๊ฐ์ ๋ฌธ์ ๊ฐ ์ฐพ์์ค๋ฆฌ๋ ์ฌ์ค์ ๋ณ์น ์์ ๊ฒ์ด๋ค. ์ง๊ธ๋ code
๋ช
๋ น์ด๋ฅผ ์น๋ฉด ํ๋ก์ธ์ค๊ฐ ์คํฐ๋์ง ์๊ณ ์๋ฌ๋ฉ์์ง๊ฐ ์ถ๋ ฅ๋๋ค.
๊ทธ๋์ ๊ทธ๋ฅ ๊ธฐ๋ณธ์ผ๋ก ๊น๋ ค์๋ wget์ ์ง์ฐ๊ณ brew๋ฅผ ์ฌ์ฉํ์ฌ ์ต์ ๋ฒ์ ์ ์ค์นํ๋ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์๋ค!
- 2023-11-07T06:11:59 ๋์๋ฐ์. ๊ณผ๊ฑฐ์ ๋์๊ฒ ์๋์ ๊ฐ์ฌ.