Cygwin下用Open SSH启动SSH服务

【删除原服务 html

若是前面已经创建过服务,可是须要从新启用服务的须要删除服务: windows

services.msc中能够看cygwin sshd的属性发现服务名为sshd app

cmd进入命令行,而后 sc delete sshd,屏幕上出现[SC] DeleteService SUCCESS, less

本质上至关于删除HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet下的注册表项 ssh

进入services.msc发现服务已删除  测试

 

【创建新服务 ui

而后进入cygwin创建ssh服务: this

1) 修改环境变量 PATH变量中加入Cygwin路径 添加CYGWIN变量设为ntsec tty spa

2) 受权: 命令行

使用windows 用户的密码和用户组 

$mkpasswd -l > /etc/passwd 

$mkgroup -l > /etc/group      

Note:   设置文件权限(若是win7须要先以管理员权限运行cygwin才能使用chmod), 在域用户的时候理论上要加-d,可是通过测试没用,仍是用上面的命令,配置好service以后直接链接127.0.0.1而后输入用户名便可,不须要其余密码之类的信息就能够本地ssh登陆了

$chmod +r /etc/group
$chmod +r /etc/passwd
$chmod +rwx /var

3) 安装:

$ ssh-host-config 

*** Info: Generating /etc/ssh_host_key

*** Info: Generating /etc/ssh_host_rsa_key

*** Info: Generating /etc/ssh_host_dsa_key

*** Info: Creating default /etc/ssh_config file

*** Info: Creating default /etc/sshd_config file

*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.

*** Info: However, this requires a non-privileged account called 'sshd'.

*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ

ME.privsep.

*** Query: Should privilege separation be used? (yes/no) yes  #输入yes

*** Info: Updating /etc/sshd_config file

 

 

*** Warning: The following functions require administrator privileges!

 

*** Query: Do you want to install sshd as a service?

*** Query: (Say "no" if it is already installed as a service) (yes/no) yes  #输入yes

*** Info: Note that the CYGWIN variable must contain at least "ntsec"

*** Info: for sshd to be able to change user context without password.

*** Query: Enter the value of CYGWIN for the daemon: [ntsec] ntsec  #输入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: You appear to be running Windows 2003 Server or later.  On 2003 and

*** Info: later systems, it's not possible to use the LocalSystem account

*** Info: for services that can change the user id without an explicit password

*** Info: (such as passwordless logins [e.g. public key authentication] via sshd). 

*** Info: If you want to enable that functionality, it's required to create a new

*** Info: account with special privileges (unless a similar account already exists).

*** Info: This account is then used to run these special servers.

*** Info: Note that creating a new user requires that the current account have

*** Info: 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  #输入no,不指定启动用户

*** Query: Create new privileged user account 'cyg_server'? (yes/no) no  #输入no,不指定启动用户

*** ERROR: There was a serious problem creating a privileged user.

*** Query: Do you want to proceed anyway? (yes/no) yes  #输入yes

*** Warning: Expected privileged user 'cyg_server' does not exist.

*** Warning: Defaulting to 'SYSTEM'

 

*** Info: The sshd service has been installed under the LocalSystem

*** Info: account (also known as SYSTEM). To start the service now, call

*** Info: `net start sshd' or `cygrunsrv -S sshd'.  Otherwise, it

*** Info: will start automatically after the next reboot.

 

*** Info: Host configuration finished. Have fun!

 

4) Windows下或者在cygwin窗口中直接 net start sshd  (sshd即为新建的服务,services.msc 中的Cygwin SSHD)

 

plus) 若是启用服务有问题能够尝试操做:

$ mkpasswd -l > /etc/passwd
$ mkgroup -l > /etc/group
$ cygrunsrv -R sshd
$ ssh-host-config -y
$ cygrunsrv -S sshd

 

另外putty链接ssh服务能够参考:

http://hi.baidu.com/liuhengloveyou/blog/item/412a1034f674cc3f5bb5f591.html

相关文章
相关标签/搜索