生成密钥
ssh-keygen
-m PEM
-t rsa
-b 4096
-C "[email protected]"
-N my_ssh_passwd
Install OpenSSH
# >>>
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
<<<
Name : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
# >>>
# 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
<<<
Path :
Online : True
RestartNeeded : False
# >>>
# 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."
}
Uninstall OpenSSH
# 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.0
Configuration OpenSSH
Default Terminal
New-ItemProperty -Path "HKLM:SOFTWAREOpenSSH" -Name DefaultShell -Value "C:WindowsSystem32WindowsPowerShellv1.0powershell.exe" -PropertyType String -Force
File
-
C:ProgramDatasshadministrators_authorized_keys
-
C:ProgramDatasshsshd_config
-
C:Users<UserName>.sshauthorized_keys
Config
-
StrictModes no
-
PubkeyAuthentication yes
-
!!! PasswordAuthentication no
!!! -
!!! PermiEmptyPasswords no
!!! -
AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
Debug Model
Stop-Service sshd
C:WindowsSystem32OpenSSHsshd.exe -d
Other
Restart-Service sshd # 重启服务
Stop-Service sshd # 停止服务
Start-Service sshd # 开启服务
原文始发于微信公众号(XRSec):Windows Install OpenSSH
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论