Windows Server 安装 OpenSSH Server
0x01 PowerShell自动安装
1、安装软件
# 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.02、启动软件
# 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.
Get-NetFirewallRule -Name *ssh*
# There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled
# If the firewall does not exist, create one
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 223、卸载软件
# Uninstall the OpenSSH Client
Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Uninstall the OpenSSH Server
Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.00x02 手动安装OpenSSH Server
github仓库 https://github.com/PowerShell/Win32-OpenSSH/releases 下载OpenSSH-Win64.zip
并且解压到C:\Program Files,其中 install-sshd.ps1 是安装文件安装sshd服务
打开powershell,执行以下命令进行安装
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1- 启动sshd服务
启动sshd服务
net start sshd或者
Start-Service sshd停止 sshd 服务
net stop sshd或者
Stop-Service sshd设置成自动
Set-Service -Name sshd -StartupType ‘Automatic’- 开启防火墙
netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22确认OpenSSH SSH Server自启动状态
win+r cmd services.msc 查看ssh server是否为自启动测试链接
$ ssh Administrator@192.168.1.101