Cygwin下用Open SSH启动SSH服务

【删除原服务

如果前面已经建立过服务,但是需要重新启用服务的需要删除服务:

services.msc中可以看cygwin sshd的属性发现服务名为sshd

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

本质上相当于删除HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet下的注册表项

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

 

【建立新服务

然后进入cygwin建立ssh服务:

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

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

转载于:https://my.oschina.net/alphajay/blog/34927

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值