Windows2012 R2配置SSH

Windows2012 R2配置SSH

𝓓𝓸𝓷 Lv6
一、下载OpenSSH
1
2
https://github.com/PowerShell/Win32-OpenSSH/releases
下载OpenSSH-Win64.zip,解压放至C:\Program Files\
二、执行安装
1
2
3
4
cmd
cd进入C:\Program Files\OpenSSH-Win64
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1

image-20220413113352761

三、修改默认22端口
1
C:\Program Files\OpenSSH-Win64\sshd_config_default
四、启动ssh
1
2
3
net start sshd

在服务里可以看到名称: OpenSSH SSH Server
五、配置开机自动启动
1
sc config sshd start= auto
六、防火墙放行端口
1
2
3
4
5
6
7
Open the firewall for sshd.exe to allow inbound SSH connections

New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

Note: New-NetFirewallRule is for Windows 2012 and above servers only. If you're on a client desktop machine (like Windows 10) or Windows 2008 R2 and below, try:

netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
七、配置环境变量
1
将C:\Program Files\OpenSSH-Win64放入系统变量Path下即可
八、远程连接测试
1
$ ssh -p 2022  administrator@192.168.1.153
九、卸载openssh
1
powershell.exe -ExecutionPolicy Bypass -File uninstall-sshd.ps1
  • Title: Windows2012 R2配置SSH
  • Author: 𝓓𝓸𝓷
  • Created at : 2024-07-07 16:55:01
  • Updated at : 2024-07-20 05:15:41
  • Link: https://www.zhangdong.me/windows-configure-ssh.html
  • License: This work is licensed under CC BY-NC-SA 4.0.
评论