windows上安装openSSH服务
OpenSSH For Windows下载链接:
https://sourceforge.net/projects/sshwindows/
https://github.com/PowerShell/Win32-OpenSSH/releases
https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH
Install Win32 OpenSSH
Install Win32 OpenSSH (test release)
-
Note these considerations and project scope first.
-
Download the latest build of OpenSSH. To get links to latest downloads this wiki page.
-
Extract contents of the latest build to
C:\Program Files\OpenSSH
(Make sure binary location has the Write permissions to just to SYSTEM, Administrator groups. Authenticated users should and only have Read and Execute.) -
In an elevated Powershell console, run the following
-
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
-
-
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
-
-
Start
sshd
(this will automatically generate host keys under %programdata%\ssh if they don't already exist)-
net start sshd
-
-
Optional
Uninstall Win32 OpenSSH
- Start Windows Powershell as Administrator
- Navigate to the OpenSSH directory
-
cd 'C:\Program Files\OpenSSH'
-
- Run the uninstall script
-
powershell.exe -ExecutionPolicy Bypass -File uninstall-sshd.ps1
-
在windows上cmd,然后ssh 主机用户@主机ip直接连到远程,很方便,如图
那么怎么配置呢?
首先windows上需要安装openSSH
1,下载openSSH windows版(注:该版本是64位)
链接: https://pan.baidu.com/s/19V2W_e1Agl4GSouW6U3JAQ
提取码: xgjp
2,解压到C:\Program Files\OpenSSH 不要放在别的路径下,官方这样要求的
3,cmd到openSSH路径下
依次执行
1)安装sshd服务
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
2)开放22号端口(如果你在windows关闭了防火墙并配置了入站规则可以不执行如下命令,多执行不影响)
netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
3)配置开机自启sshd服务
sc config sshd start= auto
到此就安装完成
4,将C:\Program Files\OpenSSH添加到path中,免得每次都要切到C:\Program Files\OpenSSH才能使用ssh,启动ssh服务
net start sshd
5,测试
首次连接未知主机会有是否继续的警告,输入yes就可以了,然后输入密码即可。
win7上没有显示[root@localhost ~]# 但不影响命令的执行。
6,ssh出于安全考虑,每次连接都会提示输入密码,为了避免麻烦,就要配置密钥对。
1)生成密钥对命令
ssh-keygen -t rsa
这里采用rsa算法,你也可以使用其他算法,但dsa默认不支持,这里是个坑,最好生成rsa密钥,ssh支持,随自己吧
2)将公钥传到远程主机的~/.ssh目录下
名字改成authorized_keys
3)修改远程主机sshd_config配置
PubkeyAuthentication yes
StrictModes no
重启sshd服务
7,cmd直连远程linux
注:以上所有操作在win7和win10上都测试通过。
About Me
........................................................................................................................ ● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除 ● 本文在itpub、博客园、CSDN和个人微 信公众号( DB宝)上有同步更新 ● 本文itpub地址: http://blog.itpub.net/26736162 ● 本文博客园地址: http://www.cnblogs.com/lhrbest ● 本文CSDN地址: https://blog.csdn.net/lihuarongaini ● 本文pdf版、个人简介及小麦苗云盘地址: http://blog.itpub.net/26736162/viewspace-1624453/ ● 数据库笔试面试题库及解答: http://blog.itpub.net/26736162/viewspace-2134706/ ● DBA宝典今日头条号地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826 ........................................................................................................................ ● QQ群号: 230161599 、618766405 ● 微 信群:可加我微 信,我拉大家进群,非诚勿扰 ● 联系我请加QQ好友 ( 646634621 ),注明添加缘由 ● 于 2020-04-01 06:00 ~ 2020-04-30 24:00 在西安完成 ● 最新修改时间:2020-04-01 06:00 ~ 2020-04-30 24:00 ● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解 ● 版权所有,欢迎分享本文,转载请保留出处 ........................................................................................................................ ● 小麦苗的微店: https://weidian.com/s/793741433?wfr=c&ifr=shopdetail ● 小麦苗出版的数据库类丛书: http://blog.itpub.net/26736162/viewspace-2142121/ ● 小麦苗OCP、OCM、高可用网络班: http://blog.itpub.net/26736162/viewspace-2148098/ ● 小麦苗腾讯课堂主页: https://lhr.ke.qq.com/ ........................................................................................................................ 使用 微 信客户端扫描下面的二维码来关注小麦苗的微 信公众号( DB宝)及QQ群(DBA宝典)、添加小麦苗微 信, 学习最实用的数据库技术。
........................................................................................................................ |
![]() |
|