cygwin架设SSH服务 http://apps.hi.baidu.com/share/detail/21392864
分类: Unix/Linux http://apps.hi.baidu.com/share/detail/21392864
From : http://www.187299.com/archives/794
综合两篇文章,成下文:
第一篇:http://hi.baidu.com/qiraosky/blog/item/35a7f144d9f3488ab3b7dc2e.html
sshd服务是一种安全连接,它能让你访问服务器上的命令行界面。Windows本身没有提供该服务,所以我们可以通过 cygwin 来进行安装。
安装 cygwin
首先安装 cygwin。安装时间为 2006-10-8,Cygwin DLL版本为 1.5.21-1。除了默认的软件包之外,又增加了以下软件包。
* Admin
o cron-3.0.1-19
o cygrunsrv-1.17-1
o shutdown-1.7-1
o syslog-ng-1.6.11-1
* Archive
o unzip-5.50-5
o zip-2.3-6
* Devel
o subversion-1.3.2-1
* Editors:
o vim-7.0.076-1
* Interpreters
o gawk-3.1.5-4
o perl-5.8.7-5
o expat-1.95.8-1
* Libs
* Net
o lftp-3.5.1-1
o openssh-4.4p1-1
o openssl-0.98d-1
o openssl097-0.9.7l-1
o ping-1.0-1
o netcat-1.10-2
* Shells
o ash-20040127-3
o bsah-3.1-9
o bash-completion-20060301-1
o mc-4.6.1-2
* Utils
o patch-2.5.8-8
o time-1.7-1
* Web
o wget-1.10.2-1
安装
用管理员用户登录,启动 cygwin 命令行,执行以下命令。
$ ssh-host-config
Generating /etc/ssh_host_key
Generating /etc/ssh_host_rsa_key
Generating /etc/ssh_host_dsa_key
Generating /etc/ssh_config file
Privilege separation is set to yes by default since OpenSSH 3.3.
However, this requires a non-privileged account called 'sshd'.
For more info on privilege separation read /usr/doc/openssh/README.privsep.
Shall privilege separation be used? (yes/no) yes
Warning: The following function requires administrator privileges!
Shall this script create a local user 'sshd' on this machine? (yes/no) yes
Generating /etc/sshd_config file
Added ssh to /cygdrive/c/WINDOWS/system32/drivers/etc/services
Do you want to install sshd as service?
(Say "no" if it's already installed as service) (yes/no) yes
Which value should the environment variable CYGWIN have when
sshd starts? It's recommended to set at least "ntsec" to be
able to change user context without password.
Default is "ntsec". CYGWIN=binmode ntsec tty
The service has been installed under LocalSystem account.
To start the service, call `net start sshd' or `cygrunsrc -S ssdh'.
Host configuration finished. Have fun!
配置 sshd
在 cygwin 的命令行中输入以下命令:
$ cd /etc
$ chmod 666 sshd_config
$ vi sshd_config
修改 sshd_config 的以下配置。
PermitRootLogin no # 禁止root登录
StrictModes yes # CYGWIN=ntsec时的安全配置
RhostsRSAAuthentication no # 禁止 rhosts 认证
IgnoreRhosts yes # 禁止 rhosts 认证
PasswordAuthentication no # 禁止密码认证
ChallengeResponseAuthentication no # 禁止密码认证
PermitEmptyPasswords no # 禁止空密码用户登录
最后将 sshd_config 的权限修改回 644。
$ chmod 644 sshd_config
启动 sshd 服务器。
$ cygrunsrv -S sshd
生成公钥和密钥
由于我们上面的设置仅允许密钥方式认证,所以要为我们的用户生成一对公钥和密钥。
在 cygwin 的控制台中执行以下命令,生成 ssh1 的公钥和密钥。
$ ssh-keygen -t rsa1
Generating public/private rsa1 key pair.
Enter file in which to save the key (/home/charlee/.ssh/identity):
Enterpassphrase (empty for no passphrase): 输入密码
Enter same passphrase again: 再次输入密码
Your identification has been sabed in /home/charlee/.ssh/identity
Your public key has been saved in /home/charlee/.ssh/identity.pub
类似的方法,使用下面的命令生成 ssh2 的公钥和密钥。
$ ssh-keygen -t rsa
$ ssh-keygen -t dsa
将公钥导入到认证公钥中:
$ cd .ssh
$ cat identity.pub >> authorized_keys
$ cat id_rsa.pub >> authorized_keys
$ cat id_dsa.pub >> authorized_keys
因为我们在 /etc/sshd_config 的配置中使用了 StrictModes yes 的设置,所以要修改目录权限,命令如下。
$ chmod 755 /home/charlee
然后将密钥 identity、id_rsa、id_dsa 文件用某种方式复制到客户端。我使用的客户端是 Linux,因此只要将这三个文件复制到客户端的 $HOME/.ssh 目录下即可。
登录服务器。在客户端上输入以下命令,即可登录服务器。
$ ssh 192.168.0.2
常见问题
2008-12-11更新
Q: cygrunsrv -S sshd不能启动,报告
cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062:
The service has not been started.
A: 很可能是/var/log的权限设置不正确。首先执行 mkpasswd 和 mkgroup 重新生成权限信息,再删除sshd服务,重新配置:
$ mkpasswd -l > /etc/passwd
$ mkgroup -l > /etc/group
$ cygrunsrv -R sshd
$ ssh-host-config -y
$ cygrunsrv -S sshd
Q: 用公钥登录时老是说Permission denied (publickey).,怎么办?
A: 可以在Windows的事件日志(我的电脑->右键->管理->事件查看器)中看到sshd产生的错误信息。常见的问题是 .ssh/authorized_keys权限设置不正确,该文件必须设置为 0644 才能正常登录。
补充:
我是装了又装,还是无法启动sshd。
出现这个错误
cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062:
The service has not been started.
除了以上所说的,还有一个可能是cygwin1.dll冲突了。
在Windows事件查看器里看到以下信息:
事件 ID ( 0 )的描述(在资源( sshd )中)无法找到。本地计算机可能没有必要的注册信息或消息 DLL 文件来从远端计算机显示消息。您可能可以使用 /AUXSOURCE= 标识来检索词描述;查看帮助和支持以了解详细信息。下列信息是事件的一部分: sshd: PID 2124: `sshd' service started.
最后tail /var/log/sshd.log,看到里面有错误信息,Google之,发现以下文章
http://jansel.javaeye.com/blog/345653
cygwin安装问题,与cntlm冲突
关键字: cygwin cntlm
安装了好多次cygwin没有成功,始终在执行到17%或者97%的地方停住。最后只好在安全模式下安装,没有想到竟然成功了。
返回到正常启动模式,发现如下问题:
Error代码
*** fatal error - system shared memory version mismatch detected - 0x2D1E009C/ 0x8A88009C.
This problem is probably due to using incompatible versions of the cygwin DLL. Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version. The most recent version *should* reside in x:cygwinbin, where 'x' is the drive on which you have
installed the cygwin distribution. Rebooting is also suggested if you
are unable to find another cygwin DLL.
照着提示,把全部硬盘扫描了一遍,发现Cntlm竟然也用到了cygwin1.dll,不过版本比较低,是24的;而我自己安装的cygwin是25的,不兼容。把Cntlm的24版本替换为25版本之后,cygwin可以正常使用,Cntlm也MS没有问题。
一点感受:cygwin的错误提示做的真的不错。再想想自己的产品。
我没有装Cntlm,但用search everything查找,发现好多地方有cygwin1.dll
D:dig
D:APMServ5.2.6nginx
D:APMServ5.2.6shell
其中D:dig加到了PATH中,估计是这个cygwin1.dll比较旧导致的。
把D:dig从PATH中移除,重启XP就可以启动了
相关推荐
Windows下的SSH安装之Cygwin
cygwin的ssh安装包,官方下载的..包括了必须的安装包,主要是为了给hadoop用的
cygwin的ssh安装包,官方下载的..包括了必须的安装包,主要是为了给hadoop用的
cygwin的ssh安装包,官方下载的..包括了必须的安装包,主要是为了给hadoop用的
cygwin的ssh安装包,官方下载的..包括了必须的安装包,主要是为了给hadoop用的
Cygwin ssh 故障总结 Cygwin ssh 故障总结
ssh-pageant, 一个用于 CYGWIN/MSYS的SSH认证代理 Putty sshCYGWIN/MSYS的SSH认证代理,它将OpenSSH链接到 Putty的Pageant 。 SSH是一个用于 Windows的小型工具,允许你使用来自 CYGWIN Pageant和 MSYS shell 环境的...
cygwin中单独摘出来的SSH模块,适应于64位windows操作系统
安装Cygwin,安装上Tcl和Expect两个工具。 百度搜索:cygwin,在搜索结果中点击:Cygwin Installation 此刻,进入cygwin软件官网,根据自己操作系统,选择32位或64的setup 双击打开下载完成的cygwin,进入安装程序...
史上最强大的windows上快速配置SSH服务的安装程序,rsync和python都一次性带上,安装极其简单,是对cygwin安装程序最好的再包装,自动配置防火墙端口规则,可安装到任意位置,卸载时也能卸载得非常干净,值得拥有
在学习hadoop的时候,在windows环境中需要通过cygwin来达到目的,这里有安装sshd服务的具体流程,本人操作过程;还有配置无密码登录的方法
win8 上还是用32位的 cygwin吧,64位的cygwin 无法运行"ssh localhost
第三步:将socks5-v1.0r11.tar.gz解压到cygwin的tmp目录下,即cygwin\tmp\socks5-v1.0r11,解压工具使用最常见的WINRAR即可。 第四步:修改cygwin\usr\include\cygwin\if.h文件,在#define IFF_LOOPBACK 0x8后...
Cygwin安装和openssh配置,Cygwin基本安装和ssh配置
Cygwin64位
Cygwin是一个在windows平台上运行的类UNIX模拟环境,是cygnus solutions公司开发的自由软件(该公司开发的著名工具还有eCos,不过现已被Redhat收购)。它对于学习UNIX/Linux操作环境,或者从UNIX到Windows的应用程序...
cygwin_lite, 小巧的cygwin虚拟机
这个是目前最新版本的cygwin安装程序。cygwin 是一个运行在windows下的一个linux模拟环境。
cygwin 是一个运行在windows下的一个linux模拟环境。
cygwin 交叉编译的 coturn 服务器可以在windows 下运行,包含运行脚本可以直接运行。