SSH installation configuration tutorial on Windows (2) - install and configure OpenSSH for Windows on Windows XP and Windows 10

Author: feipeng8848

Source: https://www.cnblogs.com/feipeng8848/p/8568018.html

This site uses " Attribution 4.0 international " Creative Commons agreement, reproduced in the article clearly indicate the position of the author and source.

 

Knowledge Summary: http://www.cnblogs.com/feipeng8848/p/8559803.html

————————————————————————

Installation There are three kinds:

(1) Windows installation packages installed directly

(2) Installation with Cygwin

(3) If Windows 10 1709 version, you can open the Win Linux subsystem 10, and installed in the subsystem.

This tutorial series server is running on the XP system, so the first method I use: Use installation package for Windows.

Installation package installed directly 1.Windows

OpenSSH For Windows Download Link:

https://sourceforge.net/projects/sshwindows/

https://github.com/PowerShell/Win32-OpenSSH/releases

 I was on the first connection download, download, unzip

Double-click the installation

Here begin the configuration

win + r open operation, an input console to perform operations to open cmd

First cd to the bin directory

Then enter the following command (performed twice)

mkgroup -l >> ..\etc\group
mkpasswd -l >> ..\etc\passwd

 

接下来在服务器的C:\OpenSSH目录上创建home目录、用户目录(以Adminstrator为例),建议使用命令,右键新建文件夹的话无法将文件夹命名为.ssh

md home\Administrator\.ssh

 下图中是依次创建的

使用写字板代开在OpenSSH安装目录下的etc\sshd_config文件,检查几个设置是否设成下面这样,确保去除前面的#号,括号中的汉字是说明该行代码的意思,sshd_config文件中并没有这些。

复制代码
Protocol 2
PermitRootLogin no            (禁止root账户登陆)
PermitEmptyPasswords no         (禁止没有密码)
PasswordAuthentication yes        (是否允许密码登陆,yes是允许,no是禁止)
RSAAuthentication yes       
PubkeyAuthentication yes   (允许公钥登陆)
AuthorizedKeysFile .ssh/authorized_keys         (公钥目录)
复制代码

 

修改注册表,指定/home的目录

运行(win+r)里输入regedit,打开注册表,然后找到如下项,修改之即可。

[HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/home]

"native"="D:\\OpenSSH\\home"

"flags"=dword:0000000a

把"native"的值改成OpenSSH安装目录下刚刚新建的/home目录

输入如下命令启动服务: 

net start opensshd

 

到这里说明已经服务端已经安装成功了OpenSSH并成功开启了服务,需要指出的是以上截图有一些是在Win10下截的,这部分与在XP上是一样的。

以Administrator账户为例,设置下Windows XP登陆密码(也就是平时的登陆密码,我设置为123456),设置好IP地址(我设置为192.168.16.1)

现在,就可以使用客户端软件登陆了。

还有一点要说,OpenSSH在客户端也需要安装,与服务端略有不同

配置的时候同样要cd到bin目录下执行这两个命令

2.使用Cygwin在Windows上安装

使用Windows安装包在服务器端安装OpenSSH for Windows配置起来非常麻烦,可以尝试使用Cygwin方式安装。

什么是CygWin?

Cygwin是一个在windows平台上运行的类UNIX模拟环境,在Windows上安装了Cygwin后就能在Win下使用Linux的很多软件,比如vim、ssh,还能使用很多Linux上的命令比如ls、cat等。

在Windows计算机上安装Cygwin教程:http://www.cnblogs.com/feipeng8848/p/8555648.html

计算机上安装了Cygwin后,就可以使用命令安装OpenSSH了

在上面的教程中已经安装了apt-cyg工具,使用个这个工具执行如下命令

apt-cyg install openssh

 我已经安装过所以这里提示我already installed。

使用which命令看一下,出现安装目录说明已经成功安装

其实使用Cygwin也可以在安装Cygwin的时候选中ssh的包,就可以不用apt-cyg命令安装了。

3.Windows 10

 在Win10下安装要方便的多,因为Win10下有一个Linux子系统,直接在开启Linux子系统使用Linux命令(apt-get install openssh)就可以安装。 

 ————————————————————

知识点汇总:http://www.cnblogs.com/feipeng8848/p/8559803.html

————————————————————

知识点汇总:http://www.cnblogs.com/feipeng8848/p/8559803.html

————————————————————————

安装方式有3种:

(1)Windows安装包直接安装

(2)使用Cygwin安装

(3)如果是Windows 10 1709版本,可以开启Win 10的Linux子系统,在子系统中安装。

本系列教程中服务器是运行在XP系统上的,所以我用的第一种方法:使用Windows下的安装包。

1.Windows 安装包直接安装

OpenSSH For Windows下载链接:

https://sourceforge.net/projects/sshwindows/

https://github.com/PowerShell/Win32-OpenSSH/releases

 我是在第一个连接上下载的,下载后解压

双击安装

下面开始配置

win+r 打开运行,输入cmd打开控制台执行如下操作

先cd到bin目录

然后输入如下命令(分两次执行)

mkgroup -l >> ..\etc\group
mkpasswd -l >> ..\etc\passwd

 

接下来在服务器的C:\OpenSSH目录上创建home目录、用户目录(以Adminstrator为例),建议使用命令,右键新建文件夹的话无法将文件夹命名为.ssh

md home\Administrator\.ssh

 下图中是依次创建的

使用写字板代开在OpenSSH安装目录下的etc\sshd_config文件,检查几个设置是否设成下面这样,确保去除前面的#号,括号中的汉字是说明该行代码的意思,sshd_config文件中并没有这些。

复制代码
Protocol 2
PermitRootLogin no            (禁止root账户登陆)
PermitEmptyPasswords no         (禁止没有密码)
PasswordAuthentication yes        (是否允许密码登陆,yes是允许,no是禁止)
RSAAuthentication yes       
PubkeyAuthentication yes   (允许公钥登陆)
AuthorizedKeysFile .ssh/authorized_keys         (公钥目录)
复制代码

 

修改注册表,指定/home的目录

运行(win+r)里输入regedit,打开注册表,然后找到如下项,修改之即可。

[HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/home]

"native"="D:\\OpenSSH\\home"

"flags"=dword:0000000a

把"native"的值改成OpenSSH安装目录下刚刚新建的/home目录

输入如下命令启动服务: 

net start opensshd

 

到这里说明已经服务端已经安装成功了OpenSSH并成功开启了服务,需要指出的是以上截图有一些是在Win10下截的,这部分与在XP上是一样的。

以Administrator账户为例,设置下Windows XP登陆密码(也就是平时的登陆密码,我设置为123456),设置好IP地址(我设置为192.168.16.1)

现在,就可以使用客户端软件登陆了。

还有一点要说,OpenSSH在客户端也需要安装,与服务端略有不同

配置的时候同样要cd到bin目录下执行这两个命令

2.使用Cygwin在Windows上安装

使用Windows安装包在服务器端安装OpenSSH for Windows配置起来非常麻烦,可以尝试使用Cygwin方式安装。

什么是CygWin?

Cygwin是一个在windows平台上运行的类UNIX模拟环境,在Windows上安装了Cygwin后就能在Win下使用Linux的很多软件,比如vim、ssh,还能使用很多Linux上的命令比如ls、cat等。

在Windows计算机上安装Cygwin教程:http://www.cnblogs.com/feipeng8848/p/8555648.html

计算机上安装了Cygwin后,就可以使用命令安装OpenSSH了

在上面的教程中已经安装了apt-cyg工具,使用个这个工具执行如下命令

apt-cyg install openssh

 我已经安装过所以这里提示我already installed。

使用which命令看一下,出现安装目录说明已经成功安装

其实使用Cygwin也可以在安装Cygwin的时候选中ssh的包,就可以不用apt-cyg命令安装了。

3.Windows 10

 在Win10下安装要方便的多,因为Win10下有一个Linux子系统,直接在开启Linux子系统使用Linux命令(apt-get install openssh)就可以安装。 

 ————————————————————

知识点汇总:http://www.cnblogs.com/feipeng8848/p/8559803.html

————————————————————

Guess you like

Origin www.cnblogs.com/gufengchen/p/10984367.html