본문 바로가기

푸로그래밍/Window

갓도우 10이상에서 ssh server 설치 및 활성화 스크립트

반응형

 Mac을 사용하다보니 윈도우가 신처럼 느껴진다.

하... 신이시여..

 

 Powershell을 이용하여 ssh-server구성요소를 설치하고 내 갓도우 PC를 ssh server로 만들어보자

매번 PC 초기설정 할 때마다 귀찮아서 그냥 정리하는 느낌으로 작성했으므로 자세하게 설명하지 않는다.

아무튼 시작

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

# 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

# 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."
}

 

 

참조: https://learn.microsoft.com/ko-kr/windows-server/administration/openssh/openssh_install_firstuse?tabs=powershell

반응형

'푸로그래밍 > Window' 카테고리의 다른 글

[Windows] 설치된 서비스를 제거하는 방법  (0) 2022.07.14