LoginSignup
1
3

More than 3 years have passed since last update.

windows10 の OpenSSH で SSH サービスが見つからない

Posted at

windows10 の OpenSSH をインストールしても SSH サービスが登録されなかった

sshd (or ssh-agent) の起動でサービスがいないよエラーが発生しているときの対処。

現象

windows 標準の OpenSSH をインストールしてみたら、sshd, ssh-agent サービスが登録されなかった。再現方法もわからない。orz

PS C:\WINDOWS\system32> .\where.exe sshd # sshd コマンドはインストールされている
C:\Windows\System32\OpenSSH\sshd.exe
PS C:\WINDOWS\system32> Start-Service sshd
Start-Service : サービス名 'sshd' のサービスが見つかりません。
発生場所 :1 文字:1
+ Start-Service sshd
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (sshd:String) [Start-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.StartServiceCommand

PS C:\WINDOWS\system32>

エラーメッセージにもある通り、sshd サービスが登録されていない。そこでwin32-OpenSSHに含まれる install-sshd.ps1 と openssh-events.man を使って sshd, ssh-agent サービスを登録する。

対処

install-sshd.ps1 は同梱の sshd.exe, ssh-agent.exe をサービスとして登録するので、そのままでは使用できない。

install-sshd.ps1 の先頭で参照する sshd.exe, ssh-agent.exe を指定しているので、これの向き先を windows にインストールされている sshd.exe, ssh-agent.exe に変更して実行する。

変更前

$scriptpath = $MyInvocation.MyCommand.Path
$scriptdir = Split-Path $scriptpath

$sshdpath = Join-Path $scriptdir "sshd.exe"
$sshagentpath = Join-Path $scriptdir "ssh-agent.exe"
$etwman = Join-Path $scriptdir "openssh-events.man"

変更後

$scriptpath = $MyInvocation.MyCommand.Path
$scriptdir = Split-Path $scriptpath

$sshdpath = Join-Path $env:SystemRoot "System32\OpenSSH\sshd.exe"
$sshagentpath = Join-Path $env:SystemRoot "System32\OpenSSH\ssh-agent.exe"
$etwman = Join-Path $scriptdir "openssh-events.man"
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3