【删除原服务】

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

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

Cygwin下用Open SSH启动SSH服务相关推荐

  1. linux 下如何用命令启动docker服务

    看截图吧,懒得说了. 1.先顺带提一个命令: # system 如果你忘了具体的system相关命令,可以这样做. 2.linux要启动docker服务,可能会需要先关闭防火墙 # systemctl ...

  2. linux下启动nfs服务,linux下Samba服务和NFS服务配置的方法

    linux下Samba服务和NFS服务配置 一.Samba服务配置过程 samba的功能很简单,就是为了使linux和windows之间能够实现共享.并且利用samba搭建文件服务器,不仅比windo ...

  3. ubuntu 下安装和启动SSH 服务

    安装OPENSSH 服务端 sudo apt-get install openssh-server 查看进程是否启动 ps -e | grep ssh 删除密钥文件 rm /etc/ssh/ssh_h ...

  4. Centos下安装SSH、FTP服务

    SSH 一.基本配置 1.rpm -qa | grep openssh 查看是否安装了ssh服务2.yum -y install sshd (yum install openssh-server)安装 ...

  5. Mac -- 启动ssh服务

    我是为了方便使用记录的,原文在这里:https://www.jianshu.com/p/52f01e967e22 mac本身安装了ssh服务,默认情况下不会开机自启 1.启动sshd服务: $ sud ...

  6. win10 linux ssh自动启动,win10子系统 wsl开机启动ssh服务

    win10子系统 wsl开机启动ssh服务 win10子系统 wsl开机启动ssh服务 一.安装ssh服务 说明:虽然已经安装了ssh服务,但是好像默认自带的不能用.所以需要先卸载再安装. 执行以下命 ...

  7. Parallels虚拟机kali linux 启动ssh服务 容许root远程登陆

    # vim /etc/ssh/sshd_config 启动ssh服务,开机启动ssh # update-rc.d ssh enable 清空known_hosts文件中的内容,再重新连接 vim /U ...

  8. 【Linux】docker安装centos8启动SSH服务并跨局域网连接

    适用于基于Docker的人工智能开发平台,或者容器内不能使用service.systemctl的情况(不能以docker run方式启动容器) 1.前言 # 能够docker run启动容器的建议加一 ...

  9. Dropbear 安装配置与启动ssh服务详解

    Dropbear 安装配置与启动ssh服务详解  扎啤 关注 2017.09.12 22:57* 字数 441 阅读 4160评论 0喜欢 0 一.介绍 dropbear作为一款基于ssh协议的轻量级 ...

  10. Ubuntu 如何启动 ssh 服务

    Ubuntu 刚安装时默认是没有启动 ssh 服务的,所以没法通过远程终端工具进行连接,开启 ssh 服务的方式很简单,就如下几步: 1.在服务器上安装 ssh 的服务器端. aptitude ins ...

最新文章

  1. 边缘计算将取代云计算?云计算前景与网络前景
  2. linux 服务器拦截http请求,详解Linux屏蔽浏览器上http请求警报的方法
  3. C#——《C#语言程序设计》实验报告——继承与多态——电视和电灯委托
  4. html div p 区别,html中div br p三者有什么区别?
  5. java 超时集合_确定性监视器脉冲/等待并在 生产环境 者 - 消费者集合中实现超时...
  6. php用script判断闰年,php判断/计算闰年的方法小结【三种方法】
  7. ubuntu18.04下安装Anaconda及numpy、matplotlib
  8. [6]Windows内核情景分析 --APC
  9. 万物互联之~RPC专栏
  10. 基于NHibernate的留言本
  11. P5516-[MtOI2019]小铃的烦恼【期望dp,线性消元】
  12. 使用juniversalchardet做字符编码识别
  13. iOS第三方地图-百度地图定位的封装
  14. 一文详解 Java 的八大基本类型!
  15. html 英文字母不换行,css如何设置英文单词不换行?
  16. 以下实例在用户点击按钮后对字符串进行反转操作
  17. 从零实现深度学习框架——逻辑回归简介
  18. linux 与 windows操作系统的区别
  19. QT - 图像处理 ( 1 ) - QImage像素级操作 - (转灰度、亮度、暖色、冷色、饱和度、模糊、锐化、金属效果 )
  20. PBR材质基础概念,限制及未来发展

热门文章

  1. c#(asp.net/core)杂谈笔记
  2. 持久化消息队列memcacheq的安装配置
  3. 寻找关键之年的榜样和标准
  4. Exception:No identifier specified for entity
  5. 微服务架构实战篇(一):使用start.spring.io 构建SpringBoot2.0项目
  6. PHPMailer 报错:SMTP ERROR: Password command failed: 535 Login Fail
  7. 结构体转map[string]interface{}的若干方法
  8. Javaweb开发之git资料
  9. marven编译时:<pre>错误: 不允许使用自关闭元素</pre>
  10. WORD出错:UNDO之后布局错乱