#author("2021-06-14T15:05:22+00:00","default:admin","admin") -[[WindowsでOpenSSHでSFTPサーバを立てる場合の設定:https://qiita.com/sibatyu/items/36c701fc43f4a9c438ca]] *Windows Server 2019・Windows10 [#y0c6ad5d] -Windows Server 2019・Windows10からはOpenSSHを公式サポート --SSHクライアントは有効化済み --SSHサーバは自分で有効化する必要あり ---サービスの初期設定は手動、停止状態なので、必要に応じて起動、自動化する -[[Windows Server 2019 および Windows 10 用 OpenSSH のインストール:https://docs.microsoft.com/ja-jp/windows-server/administration/openssh/openssh_install_firstuse]] -[[Windows Server 2019で標準サポートされた「OpenSSH」がすごく便利そうだった話:https://tech-mmmm.blogspot.com/2019/06/windows-server-2019openssh.html]] -[[OpenSSH : SSHサーバーの設定:https://www.server-world.info/query?os=Windows_Server_2019&p=ssh&f=1]] -[[FTPサーバー : SSL/TLS の設定:https://www.server-world.info/query?os=Windows_Server_2019&p=ftp&f=4]] *Windows Server 2016 [#u1e2e8f1] -[[WindowsにOpenSSHをインストールする:https://obenkyolab.com/?p=1681]] -[[WindowsServer 2016 : OpenSSH : インストール:https://www.server-world.info/query?os=Windows_Server_2016&p=openssh&f=1]] -[[WindowsにSSH (OpenSSH)をインストールする方法:https://dawaan.com/using-ssh-in-windows/]] **インストール [#q4dc7d24] -[[Install Win32 OpenSSH:https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH]] ***インストール [#f676655e] -[[https://github.com/PowerShell/Win32-OpenSSH/releases]] から最新版の OpenSSH-Win64.zip をダウンロード -zipファイルを展開し、適当なフォルダに配置 -PowerShell を管理者権限で起動し、以下を実行 powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1 ***ファイアウォールの設定 [#qe1220b8] -WindowsFirewallでPort22をOpen New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 ***起動 [#wd0c9f63] net start sshd -初回起動時に、以下に鍵ファイルが生成される C:\ProgramData\ssh ***インストール実行例 [#ga6c6f15] PS C:\opt\openssh> powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1 [*] C:\opt\openssh\moduli Inheritance is removed from 'C:\opt\openssh\moduli'. 'NT AUTHORITY\Authenticated Users' now has Read access to 'C:\opt\openssh\moduli'. 'BUILTIN\Users' now has Read access to 'C:\opt\openssh\moduli'. Repaired permissions [SC] SetServiceObjectSecurity SUCCESS [SC] ChangeServiceConfig2 SUCCESS [SC] ChangeServiceConfig2 SUCCESS sshd and ssh-agent services successfully installed PS C:\opt\openssh> New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 Name : sshd DisplayName : OpenSSH Server (sshd) Description : DisplayGroup : Group : Enabled : True Profile : Any Platform : {} Direction : Inbound Action : Allow EdgeTraversalPolicy : Block LooseSourceMapping : False LocalOnlyMapping : False Owner : PrimaryStatus : OK Status : 規則は、ストアから正常に解析されました。 (65536) EnforcementStatus : NotApplicable PolicyStoreSource : PersistentStore PolicyStoreSourceType : Local PS C:\opt\openssh> net start sshd OpenSSH SSH Server サービスを開始します.. OpenSSH SSH Server サービスは正常に開始されました。 **設定 [#g90a7c0e] ***サービス設定 [#ydc1a4f4] -サービスの画面を起動 -サービス一覧の中に「OpenSSH SSH Server」があるので、これを右クリックし、プロパティを選択 -プロパティ画面の中のスタートアップの種類を「手動」から「自動」へ変更 ***sshd_config の編集 [#aa3c13b0] -sshd_config_default をコピーして sshd_config ファイルを作成 -必要に応じて、以下項目を編集 --Port ***アクセス権限の変更 [#rde4723d] -再度、管理者権限 の PowerShell 上で OpenSSH インストールフォルダに移動 -[.\FixHostFilePermission.ps1] を実行 --インストール中の問いには全て [Y] で OK **トラブルシューティング [#q8137407] ***システム エラー 1067 が発生しました。 [#t686f0b6] -[[Error 1067- on start OpenSSH by net start opensshd in windows cmd:https://stackoverflow.com/questions/39319140/error-1067-on-start-openssh-by-net-start-opensshd-in-windows-cmd]] -解決策1:FixHostFilePermissions.ps1 の実行 powershell.exe -ExecutionPolicy Bypass -File .\FixHostFilePermissions.ps1 **アンインストール [#b4e28bb6] -管理者権限 の PowerShell 上で OpenSSH インストールフォルダに移動し、下記を実行 powershell.exe -ExecutionPolicy Bypass -File uninstall-sshd.ps1