Notice
Recent Posts
Recent Comments
Today
Total
05-04 00:14
Archives
관리 메뉴

Jeongchul Kim

Windows WSL 설치 및 SSH 설정 본문

카테고리 없음

Windows WSL 설치 및 SSH 설정

김 정출 2022. 9. 2. 11:01

Windows WSL 설치 및 SSH 설정

 

WSL을 이용하기 위해서는 Windows 10을 사용해야 합니다.

 

WSL 설치 명령어

$ wsl --install

 

설치가 완료된 후 reboot을 해줍니다.

 

WSL 설치 확인

$ wsl --status

 

WSL 측으로 ssh 접속을 위해서 openssh-server를 설치합니다.

$ sudo apt install openssh-server

 

sshd_config 파일을 수정합니다.

$ sudo su - root

$ vi /etc/ssh/sshd_config

 

다음의 파일 내용을 수정합니다.

#Port에서 #을 지워 주석을 제거하고 22번이 아닌 다른 포트(예: 22001)로 지정을 진행합니다. Windows에서 이미 22번 포트를 사용 중

다음은 Password 인증을 사용하도록 설정을 지정합니다.

PasswordAuthentication yes

 

저장 후 ssh 서버를 재시작합니다.

$ sudo service ssh --full-restart

 

WSL의 IP를 확인합니다.

$ ifconfig

 

Windows으로 복귀하여 ssh 접속을 진행합니다.

> ssh {USER_NAME}@{IP} -p {PORT_NUMBER}

 

Windows도 open-ssh 서버를 설치하면 외부망에서 WSL까지 다이렉트로 붙을 수 있습니다.

PowerShell을 사용하여 다음의 명령어를 입력합니다.

# Install the OpenSSH Client
> Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0


Open SSH 서버 설정 아래의 명령어 입력(> 제외하고)

# Start the sshd service
> Start-Service sshd

# OPTIONAL but recommended:
> Set-Service -Name sshd -StartupType 'Automatic'

# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify

> if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
    Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
    New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
    Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}

외부에서 Windows로 SSH 접속 

 

Reference: https://docs.microsoft.com/ko-kr/windows-server/administration/openssh/openssh_install_firstuse 

 

감사합니다.

 

Comments