PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# インストール可能な機能名称を確認
PS C:\Users\serverworld> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Name : OpenSSH.Client~~~~0.0.1.0
State : Installed
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
# OpenSSH Server インストール
PS C:\Users\serverworld> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Path :
Online : True
RestartNeeded : False
# サービス起動
PS C:\Users\serverworld> Start-Service -Name "sshd"
# スタートアップを [自動] に設定
PS C:\Users\serverworld> Set-Service -Name "sshd" -StartupType Automatic
# 確認
PS C:\Users\serverworld> Get-Service -Name "sshd" | Select-Object *
Name : sshd
RequiredServices : {}
CanPauseAndContinue : False
CanShutdown : False
CanStop : True
DisplayName : OpenSSH SSH Server
DependentServices : {}
MachineName : .
ServiceName : sshd
ServicesDependedOn : {}
ServiceHandle : SafeServiceHandle
Status : Running
ServiceType : Win32OwnProcess
StartType : Automatic
Site :
Container :
# Windows Firewall は 既定で [22/TCP] ポートの許可が設定されているが
# プロファイルの適用先が Private のみ
PS C:\Users\serverworld> Get-NetFirewallRule -Name OpenSSH-Server-In-TCP
Name : OpenSSH-Server-In-TCP
DisplayName : OpenSSH SSH Server (sshd)
Description : Inbound rule for OpenSSH SSH Server (sshd)
DisplayGroup : OpenSSH Server
Group : OpenSSH Server
Enabled : True
Profile : Private
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
RemoteDynamicKeywordAddresses : {}
PolicyAppId :
PackageFamilyName :
# プロファイルの適用先に Public を追加する場合は以下
PS C:\Users\serverworld> Set-NetFirewallRule -Name OpenSSH-Server-In-TCP -Profile "Private,Public"
|