安装cygwin及开启ssh

安装cygwin时一定要安装的包有:

wget 

make

yasm

lynx

openssh

libopenssl

cygwin中开启ssh的大致步骤

1、打开cygwin控制台:输入ssh-host-config 
2、提示安装成功. 输入net start sshd, 启动 ssh服务
3、采用SecureCRT进行链接:用户名和密码就是登录Windows系统的用户名和密码

以管理员身份启动cygwin后

$ ssh-host-config


*** Info: Generating missing SSH host keys
*** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes
*** Info: Creating default /etc/ssh_config file
*** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes
*** Info: Creating default /etc/sshd_config file


*** Info: StrictModes is set to 'yes' by default.
*** Info: This is the recommended setting, but it requires that the POSIX
*** Info: permissions of the user's home directory, the user's .ssh
*** Info: directory, and the user's ssh key files are tight so that
*** Info: only the user has write permissions.
*** Info: On the other hand, StrictModes don't work well with default
*** Info: Windows permissions of a home directory mounted with the
*** Info: 'noacl' option, and they don't work at all if the home
*** Info: directory is on a FAT or FAT32 partition.
*** Query: Should StrictModes be used? (yes/no) no
*** Info: Updating /etc/sshd_config file


*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no) yes
*** Query: Enter the value of CYGWIN for the daemon: [] ntsec
*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other users -- a capability
*** Info: sshd requires.  You need to have or to create a privileged
*** Info: account.  This script will help you do so.


*** Info: It's not possible to use the LocalSystem account for services
*** Info: that can change the user id without an explicit password
*** Info: (such as passwordless logins [e.g. public key authentication]
*** Info: via sshd) when having to create the user token from scratch.
*** Info: For more information on this requirement, see
*** Info: https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1


*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless such an account
*** Info: already exists). This account is then used to run these special
*** Info: servers.


*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.


*** Info: No privileged account could be found.


*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no) no
*** Query: Create new privileged user account 'LINYANG\cyg_server' (Cygwin name:                      'linyang+cyg_server')? (yes/no) yes
*** Info: Please enter a password for new user linyang+cyg_server.  Please be su                     re
*** Info: that this password matches the password rules given on your system.
*** Info: Entering no password will exit the configuration.

输入的用户名或密码要符合计算机的用户名或密码策略(尤其是公司有权限限制的电脑)
*** Query: Please enter the password:
*** Query: Reenter:


*** Info: User 'linyang+cyg_server' has been created with password 'XXXXXXXXX'.
*** Info: If you change the password, please remember also to change the
*** Info: password for the installed services which use (or will soon use)
*** Info: the 'linyang+cyg_server' account.




*** Info: The sshd service has been installed under the 'linyang+cyg_server'
*** Info: account.  To start the service now, call `net start sshd' or
*** Info: `cygrunsrv -S sshd'.  Otherwise, it will start automatically
*** Info: after the next reboot.


*** Info: Host configuration finished. Have fun!  (说明配置成功)

2 启动sshd服务
$ net start sshd

3 secureCRT中新建一个ssh2 session

hostname写127.0.0.1

port写22

username写windows的登录用户名,不是之前配置的cyg_server

然后弹出一个New Host Key的对话框,点Accept & Save 后会弹出一个窗口,输入当前windows的登录用户名及密码即可.





win7下安装cygwin及配置问题解决

1 ssh-host-config重新配置

如果初始配置错误,大部分网上都建议全部删除再重新安装,但cygwin一旦安装很难完全卸载,只需要把ssh服务停止再重新执行这个命令,再把之前的覆盖掉就可以。

步骤:  1.sc delete sshd

             2.系统重启,就再配置就ok了

 

 

 

2 cygwin安装成功后,连接 ssh localhost,一直出现

cygwin Connection closed by ::1的错误,费了很多时间查找,总算解决了,原文如下:

 

在google上看到cygwin的一个官方mail问答。参考Installing the Cygwin SSH daemon 。问题关键就是一个特殊的权限问题,在SYSTEM账户下运行的sshd服务需要有改变user id的特权(关于权限的问题,在cygwin的/usr/share/doc/Cygwin/openssh.README 中已经说得很明确了:2003 Server has a funny new feature.  When starting services under SYSTEM  account, these services have nearly all user rights which SYSTEM holds...except for the "Create a token object" right, which is needed to allow public key authentication :-( )。所以事件日志会有seteuid的错误。

至于解决方案,就是让cygwin帮你创建两个特殊用户sshd和cyg_server,其中sshd服务在cyg_server用户下运行,cyg_server有相应的权限(在/usr/share/doc/Cygwin/openssh.README 中也有说明)。

***** 关键的就是这两个用户都要创建。

猜你喜欢

转载自www.cnblogs.com/cheyunhua/p/8972269.html